i had a problem with leak. In this editingSessionArray in this line below:
NSMutableArray *sessionsArray = [[NSMutableArray alloc] initWithArray:[BBWorkoutSession fetchSessionDetail1:selectedWorkoutId]];
say that Method returns a objective-c object with a +1 retain count (owing reference):
were did i made the mistake.
Please help me
-(void)editingSessionsArray
{
[[BBAppController sharedInstance] updateLogWithString:[NSString stringWithFormat:@"BEGIN : %s", __PRETTY_FUNCTION__]];
if(selectedWorkoutId) {
// NSLog(@"the section id is : %@",selectedWorkoutId);
NSMutableArray *sessionsArray = [[NSMutableArray alloc] initWithArray:[BBWorkoutSession fetchSessionDetail1:selectedWorkoutId]];
/* condition for checking the selected workout id is existing or not */
if ([workOutSessionData count]) {
for (int i= 0; i< [workOutSessionData count] ; i++) {
if ([[[workOutSessionData objectAtIndex:i] allKeys] containsObject:[NSString stringWithFormat:@"%@",selectedWorkoutId]]) {
[workOutSessionData removeObjectAtIndex:i];
return;
}
}
}
/* If console comes here the workout id is not existed in the main array */
[mainDict setValue:sessionsArray forKey:[NSString stringWithFormat:@"%@",selectedWorkoutId]];
NSMutableDictionary *workoutsList = [[NSMutableDictionary alloc]initWithObjectsAndKeys:sessionsArray,[NSString stringWithFormat:@"%@",selectedWorkoutId],nil] ;
[workOutSessionData addObject:wor开发者_如何学GokoutsList];
[workoutsList release];
[sessionsArray release];
}
[[BBAppController sharedInstance] updateLogWithString:[NSString stringWithFormat:@"END : %s", __PRETTY_FUNCTION__]];
}
If your code goes here:
if ([workOutSessionData count]) {
for (int i= 0; i< [workOutSessionData count] ; i++) {
if ([[[workOutSessionData objectAtIndex:i] allKeys] containsObject:[NSString stringWithFormat:@"%@",selectedWorkoutId]]) {
[workOutSessionData removeObjectAtIndex:i];
return;
}
}
}
you return without releasing workoutList and sessionArray. You should allocate your sessionArray with an autorelease
NSMutableArray *sessionsArray = [[[NSMutableArray alloc] initWithArray:[BBWorkoutSession fetchSessionDetail1:selectedWorkoutId]] autorelease];
精彩评论