Search code examples
objective-csettergettersynthesize

Objective-C accessors also available without @synthesize


Consider following code:

@interface TestClass ()

@property NSString *privateProperty;

@end

Now, as I learned, to make to compiler also create the accessors, I have to add the @synthesize directive in the @implement-part.

But also, if don't add the directive, following message works:

[self setPrivateProperty:@"foo"];

From my understanding, this should lead to an error explaining me, that the selector is unknown. Why does this setter (and I think also the getter) still exist?


Solution

  • Since xcode 4.5 all properties will be synthesized automagically.