Solved

Failed to create simple table view object with Storyboard only.

Posted on 2013-10-29
2
461 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 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Learn new improvements released by Google for Google Calendar. Noted in this article are simple tips and tricks that can make your everyday use of Google Calendar better.
What is Backup? Backup software creates one or more copies of the data on your digital devices in case your original data is lost or damaged. Different backup solutions protect different kinds of data and different combinations of devices. For e…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
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.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now