Solved

Failed to create simple table view object with Storyboard only.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
You should read OS supplied guidelines before developing. I can't stress that enough. The guidelines will help you understand the reasons mobile app developers do what they do.  Apple is very particular when they review appstore submissions.
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.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

919 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

18 Experts available now in Live!

Get 1:1 Help Now