Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

phoenixreanimat

macrumors newbie
Original poster
May 12, 2009
24
0
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.



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;
	
	
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.