tags:

views:

67

answers:

2

I'm following the example Navigation View template with core data in the latest iOS SDK.

In the rootViewController.m file I see this in the @synthesize line:

@synthesize fetchedResultsController=fetchedResultsController_, managedObjectContext=managedObjectContext_;

Where the header file is:

@private
NSFetchedResultsController *fetchedResultsController_;
NSManagedObjectContext *managedObjectContext_;

}

@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;

Does this mean that they are both @synthesized (creating getters & setters) but then one is set to equal the other? It also appears that'fetchedResultsController' is also a method in the rootViewController.m file.

This template has changed in this SDK version, i'm following the Apress book More iPhone 3 development and this has really confused matters.

A: 

Only the first one (on the lhs of the synthesize statement) is synthesized with a getter and setter and becomes the "public" instance variable.

The latter (with the underscore) is still available inside the instance but is not exposed outside the instance. They both reference the same memory address.

TomH
Ok that makes sense, so is it also my understanding that the public instance also calls a method of the same name when loaded? Seems very odd, especially for an example app from the Apple documentation!I have no idea what is calling the fetchedResultsController method.
Bluey
A: 

The @synthesize syntax in your RootViewController is just setting the properties for a different name. This may be to avoid a conflict, because another method exists, or for portability. If you look in your RootViewController.h, you should see that the property is named fetchedResultsController_.

Jason McCreary