开发者

Memory leak when creating array from parts of string

timeListArray is my global variable in class Here is my Code:-

NSData *returnData = [NSURLConnection sendSynchronousRequest:requ开发者_开发问答est returningResponse:nil error:nil];
NSString *return_string5 = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
NSArray *dairyTimeParts = [return_string5 componentsSeparatedByString:@"\""];
[timeListArray removeAllObjects];

for(int i=1;i<[dairyTimeParts count]/2;i=i+2)
{
    [timeListArray addObject:[dairyTimeParts objectAtIndex:2*i+1]];
}


The problem is with this line:

NSString *return_string5 = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];

In a nutshell, anything you alloc yourself you must release when you are done with it. Try adding a [return_string5 release]; after your for loop.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜