This is another one of those tips - that are posted here as much for you as for me.
Obj-C brought with it a range of useful and time saving advances to the language. The most widely used amongst these are @property and @synthesize - if you want to know more about them follow the links. This is actually about an Error Msg you can get through forgetting some basics.
The error message in question is this clear piece of literature:
error: synthesized property 'X-Factor' must either be named the same as a compatible ivar or must explicitly name an ivar
Wow - what a mouthful - as Jinx would say.
Here's a very cut down example that would give the error message in question
@interface MyClass : NSObject
{}
@property (readwrite) BOOL X-Factor;
@end
@implementation MyClass
@synthesize X-Factor;
@end
Short huh? Can you see what the problem is - hopefully it's obvious in this example with all the other extraneous code cut away.
Our interface block (typically in the your ".h" header file) defines a property for the compiler called X-Factor and the implementation block (typically in your ".m" class file) directs the compiler to synthesize (ie. create) the setter and getter methods for an iVar called X-Factor.
Personally I think the error message could be re-written as:
error: No matching declaration in Interface block for synthesized property 'X-Factor'
To fix of course, our interface block needs this line added to it:
BOOL X-Factor;
There you go all fixed!
I've been described as a lost technocrat or an wondering luddite, personally I just like everything that takes us forward.
Leave a comment