iOS Tutorial Quick Inline Objective-C Question

Just a quick question about inline Objective-C: Can I declare a variable outside of a method? This seems like a really basic question but I haven't use inline objective-c before and wanted to be sure before proceeding.

Example:
B4X:
UIStackView *stackView =[[UIStackView alloc] init]; //This is outside the scope of methods.

- (void) myMehtod{

}
 
Last edited:

LWGShane

Well-Known Member
Licensed User
Longtime User
No.

However you don't need to use inline C to create this object:
B4X:
Dim stackView As NativeObject
stackView = stackView.Initialize("UIStackView").RunMethod("alloc", Null).RunMethod("init", Null)

I've got it working... However, it's not aligned properly and it randomly (?) tells me that the Orientation property is nil which it really isn't.

I might do a test and create the StackView via NativeObject and just have Objective-C handle the rest.
 

Attachments

  • AGStackView.zip
    3.9 KB · Views: 356
Last edited:
Top