I recently learned that you can add ivar in a class extension with LLVM2.0. (gcc can't do this) This is somehow really private iVar because other users don't it's existence since it's not in the header file. like:
//SomeClass.h
@interface SomeClass : NSObject {
}
@end
//SomeClass.m
@interface SomeClass ()
{
NSString *reallyPrivateString;
}
@end
@implementation SomeClass
@end
But this does rely on the compiler. Is there any other way to declare an ivar that's not in the header file?
The only place to declare instance variables is in the interface or a class extension (which is really an extension of the interface). But you can effectively add instance variables at any time with the modern runtime using the associated object functions.