1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Leak,please help me

Discussion in 'iPhone/iPad Programming' started by phoenixreanimat, Jul 18, 2010.

  1. macrumors newbie

    #1
    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;
    	
    	
    }
     
  2. macrumors 68030

    PhoneyDeveloper

    #2
    Did you run Build and Analyze on the code?

    What kind of object leaks?

    What line was it created on?
     

Share This Page