I wonder if it is possible to write s开发者_如何学编程omething like this in the .m file:
@interface MyController () {//ERROR here
Foo *privateFoo;
}
@end
I did it but I get :
Expected identifier or '{' before '{' token
, I think I heard/watch a video (WWDC2010) saying this is possible or will be possible and currently only some architectures support it... but I not really sure and I cannot remember the video name.
I hope I can get some advice here.
Ignacio.
You can do this in the modern runtime (64-bit/iOS) with clang (“LLVM Compiler 1.5”) in Xcode 3.2.3 or 3.2.4, by adding -Xclang -fobjc-nonfragile-abi2
to the Other C Flags build setting. (Note that this is actually one option, not two.)
Another effect of this flag is to cause properties to be synthesized by default.
It is not possible to handle it this way. Categories define additional behaviour only, not state.
Albeit it doesn't state it explicitly, and the thread is pretty old, this document has an example at page 75 in which an ivar is added within an extension.
The Objective-C Programming Language
精彩评论