SundayMonday SundayMonday - 7 months ago 60
Objective-C Question

Are curly braces required in @interface declarations in Objective-c?

The following code compiles:

@interface MyClass : ParentClass // missing {
// missing }
@property (nonatomic, copy) NSString *myString;

I'm wondering if the curly braces in
declarations are actually necessary.


No, the { } section isn’t necessary; your code will compile fine without it. It’s the area where you declare instance variables, and if you’re not doing that, you’re free to leave it out. You don’t even actually need to declare ivars for your properties—the compiler’s smart enough to add them where they’re needed.