Created
October 10, 2012 05:24
Revisions
-
JFK revised this gist
Oct 10, 2012 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ // MemoryLeakTestTableViewController.m // MemoryLeakTest @interface MemoryLeakTestTableViewController : UITableViewController { NSMutableArray *dataForCellArray1; } @@ -30,17 +30,17 @@ - (void)viewDidLoad { [super viewDidLoad]; NSMutableArray *dataForCellArray = [NSMutableArray array]; for (int i = 0; i < 10; i++) { [dataForCellArray addObject:[NSString stringWithFormat:@"Cell Row %d", i]]; } dataForCellArray1 = [dataForCellArray mutableCopy]; self.dataForCellArray2 = [dataForCellArray mutableCopy]; self.dataForCellArray3 = [[NSMutableArray alloc] initWithArray:dataForCellArray]; self.dataForCellArray4 = [[[NSMutableArray alloc] initWithArray:dataForCellArray] autorelease]; self.sections = [[[NSMutableArray alloc] init] autorelease]; for (int i = 0; i < 4; i++) { [self.sections addObject:[NSString stringWithFormat:@"dataForCellArray%d", i]]; -
JFK renamed this gist
Oct 10, 2012 . 1 changed file with 12 additions and 24 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,21 +33,17 @@ - (void)viewDidLoad NSMutableArray *dataForCellArray = [NSMutableArray array]; for (int i = 0; i < 10; i++) { [dataForCellArray addObject:[NSString stringWithFormat:@"Cell Row %d", i]]; } dataForCellArray1 = [dataForCellArray mutableCopy]; self.dataForCellArray2 = [dataForCellArray mutableCopy]; self.dataForCellArray3 = [[NSMutableArray alloc] initWithArray:dataForCellArray]; self.dataForCellArray4 = [[[NSMutableArray alloc] initWithArray:dataForCellArray] autorelease]; self.sections = [[[NSMutableArray alloc] init] autorelease]; for (int i = 0; i < 4; i++) { [self.sections addObject:[NSString stringWithFormat:@"dataForCellArray%d", i]]; } } @@ -61,14 +57,12 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView return [self.sections count]; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return [self.sections objectAtIndex:section]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section == 0) { return [dataForCellArray1 count]; @@ -82,29 +76,23 @@ - (NSInteger)tableView:(UITableView *)tableView return 0; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } if (indexPath.section == 0) { cell.textLabel.text = [dataForCellArray1 objectAtIndex:indexPath.row]; } else if (indexPath.section == 1) { cell.textLabel.text = [dataForCellArray2 objectAtIndex:indexPath.row]; } else if (indexPath.section == 2) { cell.textLabel.text = [self.dataForCellArray3 objectAtIndex:indexPath.row]; } else if (indexPath.section == 3) { cell.textLabel.text = [self.dataForCellArray4 objectAtIndex:indexPath.row]; } return cell; } @end -
CodeIQ created this gist
Oct 9, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,110 @@ // // MemoryLeakTestTableViewController.m // MemoryLeakTest @interface MemoryLeakTestTableViewController () { NSMutableArray *dataForCellArray1; } @property (retain, nonatomic) NSMutableArray *dataForCellArray2; @property (retain, nonatomic) NSMutableArray *dataForCellArray3; @property (retain, nonatomic) NSMutableArray *dataForCellArray4; @property (retain, nonatomic) NSMutableArray *sections; @end @implementation MemoryLeakTestTableViewController @synthesize dataForCellArray2; @synthesize dataForCellArray3; @synthesize dataForCellArray4; @synthesize sections; - (void)dealloc { [dataForCellArray1 release]; [dataForCellArray2 release]; [dataForCellArray3 release]; [super dealloc]; } - (void)viewDidLoad { [super viewDidLoad]; NSMutableArray *dataForCellArray = [NSMutableArray array]; for (int i = 0; i < 10; i++) { [dataForCellArray addObject:[NSString stringWithFormat:@"Cell Row %d", i]]; } dataForCellArray1 = [dataForCellArray mutableCopy]; self.dataForCellArray2 = [dataForCellArray mutableCopy]; self.dataForCellArray3 = [[NSMutableArray alloc] initWithArray:dataForCellArray]; self.dataForCellArray4 = [[[NSMutableArray alloc] initWithArray:dataForCellArray] autorelease]; self.sections = [[[NSMutableArray alloc] init] autorelease]; for (int i = 0; i < 4; i++) { [self.sections addObject:[NSString stringWithFormat:@"dataForCellArray%d", i]]; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [self.sections count]; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return [self.sections objectAtIndex:section]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section == 0) { return [dataForCellArray1 count]; } else if (section == 1) { return [dataForCellArray2 count]; } else if (section == 2) { return [self.dataForCellArray3 count]; } else if (section == 3) { return [self.dataForCellArray4 count]; } return 0; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } if (indexPath.section == 0) { cell.textLabel.text = [dataForCellArray1 objectAtIndex:indexPath.row]; } else if (indexPath.section == 1) { cell.textLabel.text = [dataForCellArray2 objectAtIndex:indexPath.row]; } else if (indexPath.section == 2) { cell.textLabel.text = [self.dataForCellArray3 objectAtIndex:indexPath.row]; } else if (indexPath.section == 3) { cell.textLabel.text = [self.dataForCellArray4 objectAtIndex:indexPath.row]; } return cell; } @end