Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Failed to create simple table view object with Storyboard only.

Posted on 2013-10-29
2
Medium Priority
?
541 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
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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

There is a security feature on iOS devices that is nearly impenetrable when it has been activated.  This article will provide some possible solutions as well as necessary steps to take to ensure you do not end up with a locked device.
Email is way too noisy, prone to hiding the important stuff, and really becoming unreliable for critical/timely communications. There are better ways to communicate.
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…

972 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