Declaration.
@property (nonatomic, retain) footballResultsParser * FBRP;
Method of alloc.
-(void) viewDidLoad
{
if (FBRP == nil)
{
FBRP = [[footballResultsParser alloc] init];
[FBRP updateResults];
}
}
Is that the proper and safe way you alloc objects in your viewDidLoad?
I assume its possible that viewDidLoad will get called more than once and the object might already exists.
To dealloc safely.
-(void) dealloc
{
if (FBRP != nil)
{
[FBRP release];
}
}
Is there a better way to do memory management that this?
You should also release them in viewDidUnload. For reference, here is the related documentation in the UIViewController class reference.
Btw, when releasing, you don’t have to check if the object is nil. Sending messages to nil does nothing, it’s safe.