Leak,please help me

Discussion in 'iOS Programming' started by phoenixreanimat, Jul 18, 2010.

  1. phoenixreanimat
    Expand Collapse
    macrumors newbie

    May 12, 2009
    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 *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;
  2. PhoneyDeveloper
    Expand Collapse
    macrumors 68030


    Sep 2, 2008
    Did you run Build and Analyze on the code?

    What kind of object leaks?

    What line was it created on?

Share This Page