PDA

View Full Version : Leak,please help me




phoenixreanimat
Jul 18, 2010, 03:53 PM
Hi, I am a new IPhone developer and deal with memory leak.
I use instruments to find my memory leak.
This is my code, I know is very ugly. How can I to make it perfect without leak? I know I need to learn much things and thanks for help me.



NSArray *arr = [NSArray arrayWithObjects: @"b........b",nil];

NSMutableArray *chips2D= [self to2DAry:arr];

-(NSMutableArray*)to2DAry:(NSArray*)ary
{
NSMutableArray *returnAry = [[NSMutableArray alloc]init];
NSString *str;
NSString *str1;
NSMutableArray *tempMAry;
for (unsigned int i=0; i<[ary count]; i++) {
str = [ary objectAtIndex:i] ;
tempMAry = [[NSMutableArray alloc]init];
for (unsigned int j = 0; j<[str length]; j++) {
str1 = [str substringWithRange: NSMakeRange(j, 1)];
[tempMAry addObject:str1];
}
[returnAry addObject:tempMAry];

}
return returnAry;


}



PhoneyDeveloper
Jul 18, 2010, 06:34 PM
Did you run Build and Analyze on the code?

What kind of object leaks?

What line was it created on?