SundayMonday SundayMonday - 9 days ago 6
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;
@end


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

Answer

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.