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.
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.
Code:
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;
}