/ Published in: iPhone
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
.h file: @interface ResultsViewController : UITableViewController { NSMutableArray *m_list; } @end ======================= .m file: @implementation ResultsViewController //@synthesize m_resultsDetailViewController; @synthesize m_list; //@synthesize m_resultCellDict; #pragma mark - #pragma mark View lifecycle - (void)viewDidLoad { [super viewDidLoad]; NSDictionary *tempDict; AdInfo *shAdInfo = [AdInfo sharedAdInfo]; tempDict = shAdInfo.adInfoDict; int nCountDict = [tempDict count]; NSLog(@"nCountDict: %d", nCountDict); //////////////////////// int ctr; NSDictionary *localDict; for(ctr = 1; ctr <= nCountDict; ctr++) { [myMutableArr addObject:localDict]; } self.m_list = myMutableArr; [myMutableArr release]; NSLog(@"m_list count: %d", [m_list count]); } #pragma mark - #pragma mark Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [m_list count]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // Configure the cell... NSUInteger row = [indexPath row]; //NSLog(@"newDict desc: %@", [newDict description]); cell.textLabel.text = rowString; [rowString release]; return cell; } #pragma mark - #pragma mark Table view delegate // Navigation logic may go here. Create and push another view controller. NSUInteger row = [indexPath row]; ResultsDetailViewController *resultsDetailViewController = [[ResultsDetailViewController alloc] initWithNibName:@"ResultsDetailView" bundle:nil withDictionary:rowDetails]; // Pass the selected object to the new view controller. [self.navigationController pushViewController:resultsDetailViewController animated:YES]; [resultsDetailViewController release]; resultsDetailViewController = nil; //[rowDetails release]; //rowDetails = nil; } #pragma mark - #pragma mark Memory management - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Relinquish ownership any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand. // For example: self.myOutlet = nil; self.m_list = nil; [super viewDidUnload]; } - (void)dealloc { [m_list release]; [super dealloc]; }