What happened to putting ivar in a class extension?

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

@interface Menu () { int testIvar; } -(void)privateMethod; @end 

This works if I'm not trying to declare iVar. As soon as I add curly braces and what's in between, I get this red warning:

The expected identifier or '(' before '{' token

What's going on here?

+4
source share
1 answer

(translating my comment in response ...)

GCC of any type will not do this for you, and LLVM <2.0, as the documents you linked to the state:

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

Make sure you use the latest compiler available to you (if you use Xcode <4, you might be out of luck).

+4
source

Source: https://habr.com/ru/post/1399124/


All Articles