UITableView ObjectAtIndex?

Assuming table is your UITableView the call to table objectAtIndex:indexPath. Row is completely nonsensical. It looks to me like you should be calling pages objectAtIndex:indexPath.

Row instead.

Up vote 1 down vote favorite share g+ share fb share tw.

I'm developing an iPhone app that is a tabViewController with one of the tabs including a tableView. Objects in the table can be touched to go to a splash screen with information for that specific object. Here's how I set up the array tableView: -(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ //each table view cell has its own identifier.

Static NSString *cellIdentifier = @"CellIdentifier"; UITableViewCell *cell = tableView dequeueReusableCellWithIdentifier:cellIdentifier; if (cell == nil) { cell = UITableViewCell alloc initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier autorelease; } NSUInteger row = indexPath row; cell.textLabel. Text = sitesArray objectAtIndex:row; cell.imageView. Image = imagesArray objectAtIndex:row; cell.

AccessoryType = UITableViewCellAccessoryDetailDisclosureButton; return cell; } - (void)viewDidLoad { NSArray *pageHolder = NSArray alloc initWithObjects:@"CSLP", @"NSLS", @"LSPA", @"SIOP", @"Transfer", nil; self. Pages = pageHolder; pageHolder release; NSArray *sites = NSArray alloc initWithObjects:@"CSLP", @"NSLS", @"LSPA", @"SIOP", @"Transfer Vision Program ", nil; self. SitesArray = sites; UIImage *cslp = UIImage imageNamed:@"CSLP LOGO.

Png"; UIImage *nsls = UIImage imageNamed:@"NSLS LOGO. Png"; UIImage *lspa = UIImage imageNamed:@"LSPA LOGO. Png"; UIImage *siop = UIImage imageNamed:@"SIOP LOGO.

Png"; UIImage *transfer = UIImage imageNamed:@"TRANSFER LOGO. Png"; NSArray *images = NSArray alloc initWithObjects: cslp, nsls, lspa, siop, transfer, nil; sites release; self. ImagesArray = images; UIButton* modalViewButton = UIButton buttonWithType:UIButtonTypeRoundedRect; modalViewButton addTarget:self action:@selector(modalViewAction:) forControlEvents:UIControlEventTouchUpInside; UIBarButtonItem *modalBarButtonItem = UIBarButtonItem alloc initWithCustomView:modalViewButton; self.navigationItem.

RightBarButtonItem = modalBarButtonItem; modalBarButtonItem release; self. Table reloadData; } And here's my didSelectRowAtIndexPath method -(void) tableView:(UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath { NSInteger row = indexPath row; NSMutableDictionary *rowData = table objectAtIndex:indexPath. Row; UIViewController *targetViewController = rowData objectForKey:kViewControllerKey; if (!targetViewController) { // The view controller has not been created yet, create it and set it to our menuList array NSString *viewControllerName = pages objectAtIndex:indexPath.

Row stringByAppendingString:@"ViewController"; targetViewController = NSClassFromString(viewControllerName) alloc initWithNibName:viewControllerName bundle:nil; rowData setValue:targetViewController forKey:kViewControllerKey; targetViewController release; } SSARC_App_2AppDelegate *delegate = UIApplication sharedApplication delegate; delegate. OrgsNavigationController pushNavigationItem:targetViewController animated:YES; delegate release; } The application crashes at the first call to objectAtIndex in the didSelectRowAtIndexPath method. The console states: 010-11-22 12:50:17.113 SSARC App 243470:207 -UITableView objectAtIndex:: unrecognized selector sent to instance 0x601e800 2010-11-22 12:50:17.116 SSARC App 243470:207 * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-UITableView objectAtIndex:: unrecognized selector sent to instance 0x601e800' * Call stack at first throw: Now, I have a warning that says "UITableView may be unresponsive to ObjectAtIndex".

I'm assuming this is the main issue here, however I'm unsure how to solve it. Interestingly enough I've searched for this issue everywhere, and cannot find it anywhere, so I'm curious to know if anyone has run into this problem and how to solve it. Any advice would be great.

Let me know if you need more information. Thanks, Baker iphone cocoa-touch uitableview uinavigationbar link|improve this question edited Nov 22 '10 at 22:26vikingosegundo10.9k51234 asked Nov 22 '10 at 21:16Baker61.

Can you show the property declaration of sitesArray – vikingosegundo Nov 22 '10 at 22:19 Can you show the property declaration of sitesArray, imagesArray and pages – vikingosegundo Nov 22 '10 at 22:25 Hello! The property definition of those arrays are as follows: @property (nonatomic, retain) NSArray *pages; @property (nonatomic, retain) NSArray *imagesArray; @property (nonatomic, retain) NSArray *sitesArray; – Baker Nov 24 '10 at 22:03.

Assuming table is your UITableView, the call to table objectAtIndex:indexPath. Row is completely nonsensical. It looks to me like you should be calling pages objectAtIndex:indexPath.

Row instead.

Thank you for that information. After changing the call to pages instead of table I still crash, but it says 'NSInvalidArgumentException', reason: '-NSCFString objectForKey:: unrecognized selector sent to instance 0x708c' now. – Baker Nov 24 '10 at 22:07 My viewDidLoad also has been changed to: if (!pages) { pages = NSArray alloc initWithObjects:@"CSLP", @"NSLS", @"LSPA", @"SIOP", @"Transfer", nil; } //menuLIst == sitesArray for (NSString *pageName in pages) { self.

SitesArray addObject:NSMutableDictionary dictionaryWithObjectsAndKeys: NSLocalizedString(pageName stringByAppendingString:@"Title", @""), kTitleKey, NSLocalizedString(pageName stringByAppendingString:@"Explain", @""), kDetailKey, nil; } In place of the old initialization for pages. – Baker Nov 24 '10 at 22:10.

I've been doing some coding on my own and I've gotten it to compile without any errors or warnings, but it still crashes. Currently this is what I have: NSMutableDictionary *rowData = self. MenuList objectAtIndex:indexPath.

Row; UIViewController *targetViewController = rowData objectForKey:kViewControllerKey; if (!targetViewController) { // The view controller has not been created yet, create it and set it to our menuList array NSString *viewControllerName = pages objectAtIndex:indexPath. Row stringByAppendingString:@"ViewController"; targetViewController = NSClassFromString(viewControllerName) alloc init;//WithNibName:viewControllerName bundle:nil; NSLog(@"targetViewController: %@", targetViewController); rowData setValue:targetViewController forKey:kViewControllerKey; targetViewController release; } SSARC_App_2AppDelegate *delegate = (SSARC_App_2AppDelegate*)UIApplication sharedApplication delegate; delegate orgsNavigationController pushViewController:targetViewController animated:YES; delegate release; delegate = nil; The issue that the debugger reports is that 'viewControllerName' is 'Out of Scope'. I don't really understand what that means because when I use NSLog, viewControllerName is initialized.

Does that mean it cannot find the class I'm referring to? Please let me know. Thanks, Baker.

Also, I just want to note that uncommeting initWithNibName doesn't work as well. – Baker Dec 1 '10 at 21:28.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions