Under what conditions is @synthesize automatic in Objective-c?

As of clang 3.2 (circa February 2012), “default synthesis” (or “auto property synthesis”) of Objective-C properties is provided by default. It’s essentially as described in the blog post you originally read: http://www.mcubedsw.com/blog/index.php/site/comments/new_objective-c_features/ (except that that post describes the feature as “enabled, then disabled”; I don’t know if that’s an issue with Xcode or if the … Read more

Difference between _ and self. in Objective-C

self.myString = @”test”; is exactly equivalent to writing [self setMyString:@”test”];. Both of these are calling a method. You could have written that method yourself. It might look something like this: – (void)setMyString:(NSString*)newString { _myString = newString; } Because you used @synthesize, you don’t have to actually bother writing that method, you can just allow the … Read more

@synthesize vs @dynamic, what are the differences?

@synthesize will generate getter and setter methods for your property. @dynamic just tells the compiler that the getter and setter methods are implemented not by the class itself but somewhere else (like the superclass or will be provided at runtime). Uses for @dynamic are e.g. with subclasses of NSManagedObject (CoreData) or when you want to … Read more