How to release memory for declared object in iPhone
i'm suffering with small problem,
I declare array at .h file, and array allocation at viewDodLoad, in
dealloc method i wrote if array not equal to nil then array=nil. but it's
crashing in iOS 5.1.1. i cann't understand what is the problem for crash.
below code i wrote
@interface SampleApp : UIViewController
{
NSMutableArray *objArray;
}
@end
@implementation SampleApp
- (void)viewDidLoad
{
[super viewDidLoad];
objArray=[[NSMutableArray alloc]init];
}
-(void)dealloc
{
[super dealloc];
if (objArray!=nil)
{
[objArray removeAllObjects];
[objArray release];objArray=nil;
}
}
No comments:
Post a Comment