I am still learning Objective-C memory management. I am trying to implement some simple classes in an example program that I am creating.
As an example, let's say I have the following class definition:
#import <UIKit/UIKit.h>
@interface customViewController : UIViewController
{
customObject *myCustomObject;
}
@property (retain) customObject *myCustomObject;
- (void)replaceCustomObject:(customObject *)newObject;
@end
For the property, I use the standard synhesize keyword ...
@synthesize myCustomObject;
Then, please assume that in the customViewController instance myCustomObject is already set to a valid value and is used. Then the replaceCustomObject method is defined as:
- (void)replaceCustomObject:(customObject *)newObject
{
self.myCustomObject = newObject;
}
As a comment observes, does this memory leak? Or is this a valid way to replace the previous object with a new object?
Thanks
Frank