Solved

Failed to create simple table view object with Storyboard only.

Posted on 2013-10-29
2
487 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

iCloud Drive was introduced after iOS 8 was launched last year. This drive is Apple’s online storage device that lets users sync their files and access them from all their Apple devices.   There is a lot of data that is not automatically backed up…
A brief look into what is, how to use, and how to make GIFs
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 video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

752 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