Solved

Failed to create simple table view object with Storyboard only.

Posted on 2013-10-29
2
497 Views
Last Modified: 2013-11-21
When i try to create a simple project which add a Table View object into default view controller, it failed to run with below error

[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x793ad0
(Screenshot pic 1)

Any idea what is missing?
Thank you.

I just start to lear IOS app development, want to use Storyboard to do it, not xib file.
Xcode 4.6
iPhone simulator
1-Error-Code.jpg
2-Step1-add-table-view-object-to.jpg
3-Step3-Link-dataSource-and-Dele.jpg
4-Step2-modify-ViewController..h.jpg
5-Step3-modify-ViewController.m-.jpg
0
Comment
Question by:dickchan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Expert Comment

by:FutureIOSGuru
ID: 39608296
You should definitely try moving your viewDidLoad method to the viewWillAppear:Animated.  It seems to me that the viewDidLoad method is one that is used when a view is loaded from a nib file.  The viewWillAppear and viewDidAppear methods are the ones that I use for my storyboards.

Also, since your list variable isn't really exposed, I'd suggest moving that to the .m file in the same manner
@interface ViewController() {
      NSMutableArray *VCList;
}
@end

@implementation ViewController

- (void)viewWillAppear:(BOOL)animated
{
     VCList = [@[] mutableCopy];
     [VCList addObject:@"Apples"];
     [VCList addObject:@"Bananas"];
     [VCList addObject:@"Lemo"];
     NSLog(@"VCList count: %d", VCList.count);
}

Open in new window


Also, I make pretty heavy use of NSLog().  It's easy to stick into your code and get out some details while the program is running.  Then you can see when the method has loaded and that the variable is ready to go.   Likely your viewDidLoad method never got called, you can always use breakpoints or logging to make sure that your methods are being invoked.

Enjoy!
0
 
LVL 9

Accepted Solution

by:
EZFrag earned 500 total points
ID: 39644719
Hi there,

Make sure that your viewcontroller's custom class property is set to the class name of your viewcontroller. In your case, it seems that it should be "ViewController".

The error
[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x793ad0

Open in new window

indicates that it is still using the default UIViewController, and not your custom ViewController class.

Custom Class
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The release of the iPhone 6 and iPhone 6 Plus was a complete game changer for Apple. Steve Jobs had even showed his distaste for larger phones, calling them “Hummers”. But to compete with larger smartphones, Apple finally introduced the iPhone 6 wit…
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question