iphone - NSMutableArray elements not being released in dealloc -
i have define nsmutablearray in .h file
nsmutablearray *arraybatlevel;
init in .m file
- (void)viewdidload { [super viewdidload]; [self datatimer]; } -(void)datatimer { [recorddatatimer invalidate]; recorddatatimer = [nstimer scheduledtimerwithtimeinterval:[timeinterval.text floatvalue] target:self selector:@selector(recorddata) userinfo:nil repeats:yes]; } -(void)recorddata { if ([aswitch ison] == yes) { if (arraybatlevel == nil) { arraybatlevel = [[nsmutablearray alloc] init]; nslog(@"alloc arraybatlevel"); } [arraybatlevel addobject:batlevel.text]; } }
and release in dealloc
- (void)dealloc { [arraybatlevel release]; [super dealloc]; }
but, seems it’s not releasing objects inside nsmutablearray
. when exit app , run gain, these objects still in nsmutablearray, why?
your problem not array, it's objects inside array. don't indicate "batlevel" came from. i'm guessing "batlevel" retained somewhere else, , "batlevel.text".
Comments
Post a Comment