0
我一直在行內存泄漏tempstr = [tempstr substringToIndex ... 我試過每種可能的分配tempStr組合, NSString * tempStr = @「」; NSString * tempStr = [[NSString alloc] init]; (在循環結束時發佈) 我嘗試調整NSString的範圍。沒有。它生產3泄漏 任何幫助,我可以嘗試解決它將不勝感激。substringToString產生泄漏
while(x < [arr1 count]){
//NSLog(@"%@", [arr1 objectAtIndex:x]);
if([[arr1 objectAtIndex:x] rangeOfString:@".com"].location != NSNotFound)
{
//NSLog(@"%@", [arr1 objectAtIndex:x]);
tempStr = [[arr1 objectAtIndex:x] substringFromIndex:[[arr1 objectAtIndex:x] rangeOfString:@"http://"].location];
tempStr = [tempStr substringToIndex:tempStr.length - 1];
[arr1 replaceObjectAtIndex:x withObject:tempStr];
//NSLog(@"%@", [arr1 objectAtIndex:x]);
}
..... more code....
x++
}
我一直在假設我的autorelease池設置不正確。據我所知,它應該爲我自動完成...我是不正確的? – Riley 2011-03-31 23:14:25
'NSString * tempStr = [[arr1 objectAtIndex:x] substringFromIndex:[[arr1 objectAtIndex:x] rangeOfString:@「http://」] .location]; tempStr = [tempStr substringToIndex:tempStr.length - 1]; [arr1 replaceObjectAtIndex:x withObject:tempStr]; '也泄漏 – Riley 2011-03-31 23:14:49