Question

According to Apple's documentation here, this should work in my code:

@interface Menu () {
    int testIvar;

}
 -(void)privateMethod;

@end

This works if I don't try to declare an iVar. As soon as I add the curly braces and what is between them, I get this nice red warning:

Expected identifier or '(' before '{' token

What's going on here?

Was it helpful?

Solution

(Turning my comment into an answer...)

GCC of any kind won't do this for you, nor will LLVM < 2.0, as the docs you linked to state:

Using the Clang/LLVM 2.0 compiler, you can also declare properties and instance variables in a class extension.

Make sure you're using the most recent compiler available to you (if you're using Xcode < 4 you may be out of luck).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top