SundayMonday SundayMonday - 1 year ago 92
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download