Using property and synthesis, you get a new method. In this case, you will have a new set and get method for detailedResultsTableViewController
. This is generated for you during compilation (i.e. there is no code you have to add)
This installation method will
- (void)setDetailedResultsTableViewController:(DetailedResultsTableViewController *)c { if (detailedResultsTableViewController != nil) { [detailedResultsTableViewController release]; detailedResultsTableViewController = nil; } detailedResultsTableViewController = [c retain]; }
So when you call
self.detailedResultsMapViewController = [[DetailedResultsMapViewController alloc] init...];
What you are actually calling
[self setDetailedResultsMapViewController:[[DetailedResultsMapViewControler...]]]
So, you are actually making two saves. When you call alloc ... init. and then another because you are implicitly calling setDetailedResultsMapViewController, which then also saves.
If you use properties, you should use
DetailedResultsTableViewController *d = [[DetailedResultsMapViewController alloc] init...] self.detailedResultsMapViewController = d; [d release];
The advantage of this is that you do not need to remember the release of the old object before assigning the new one, since the synthesized method does this for you. You can also just do
self.detailedResultsMapViewController = nil;
in your dealloc method, and you wonβt have to worry if you already released it elsewhere.
This is useful to know because you can override the set method by manually entering code that allows you to do things when objects are set.
source share