views:

48

answers:

2

I wonder if it is possible to write something 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.

A: 

It is not possible to handle it this way. Categories define additional behaviour only, not state.

jer
That isn't a category, it is a class extension. The rules are quite different.
bbum
I'm aware they're slightly different semantically, as described here: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocCategories.html#//apple_ref/doc/uid/TP30001163-CH20-SW1 ... However, nowhere there does it say one can add instance variables to extensions. Please point me at some resource there which does describe that behaviour, and I'll go ahead and remove my answer.
jer
+2  A: 

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.

Ahruman
This is what I was looking for, thanks!
nacho4d