I have an anonymous struct in my code that I’d like to access via an assign @property (no pointer). However, since this is an anonymous structure. Here’s the cocoa code I created (even if it’s cocoa code, it’s relevant to objective-c in general.)
@interface ProfileViewController : UIViewController {
struct {
BOOL isDeviceOwner:1;
} _statusFlags;
}
Now I’d like to create a property for _statusFlags:
@property (nonatomic, assign)
Yes, you just define it inline where you would define the type.
@property (nonatomic, assign) struct { ... } statusFlags;Then when you synthesize it you can do
@synthesize statusFlags = _statusFlagsif you really like the underscored ivars, but this will generate the ivar for you. You do not need to define it explicitly.