当在文书中对这一守则进行描述时,我发现35名运动员的记忆泄露。 如何应对以避免记忆泄露?
NSMutableArray *players = [NSMutableArray array];
NSData *data = [theRequest responseData];
NSArray *array = (NSArray *) [decoder objectWithData:data];
int len = 35;
for (int i = 0; i < len; i++) {
NSDictionary *dic = (NSDictionary *) [array objectAtIndex:i];
Player *p = [[Player alloc] init];
p.playerID = [dic objectForKey:@"id"];
p.name = [dic objectForKey:@"name"];
p.country = [dic objectForKey:@"country"];
p.club = [dic objectForKey:@"club"];
p.imageURL = [dic objectForKey:@"image"];
p.likeNumber = [dic objectForKey:@"like_number"];
p.likeTime = [dic objectForKey:@"like_time"];
p.likePlayerID = [dic objectForKey:@"like_player_id"];
p.likeDeviceID = [dic objectForKey:@"like_device_id"];
p.disLikeNumber = [dic objectForKey:@"dislike_number"];
p.disLikeTime = [dic objectForKey:@"dislike_time"];
p.disLikePlayerID = [dic objectForKey:@"dislike_player_id"];
p.disLikeDeviceID = [dic objectForKey:@"dislike_device_id"];
[players insertObject:p atIndex:i];
[p release];
}