iphone - Problem with memory manament in Objective-C -
i have method: -(nsarray *)dosomething{ nsarray *array = [[nsarray alloc] initwithobjects:@"huy 1",@"huy 2",@"huy 3",nil]; [array release]; return array; } and - (void)viewdidload { [super viewdidload]; nsarray *array = [self dosomething]; if(array&&array.count>0){ nslog([nsstring stringwithformat:@"%@\n",[array objectatindex:1]]); } else{ nslog(@"null"); } } i thinks released array on dosomething() won't return nsarray created on dosomething(). don't know still print "huy 2"? can tell me why? -(nsarray *)dosomething { nsarray *array = [[nsarray alloc] initwithobjects:@"huy 1",@"huy 2",@"huy 3",nil]; return [array autorelease]; } memory management programming guide - (void)viewdidload { [super viewdidload]; nsarray *array = [self dosomething]; if([array co...