Note that there are some explanatory texts on larger screens.

plurals
  1. POtableview not working - [UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance
    primarykey
    data
    text
    <p>I'm trying to init a <code>uitableview</code> using <code>xib</code> but when I run the app in simulator, the below exception is thrown.</p> <pre><code>2013-06-16 10:40:48.552 CoreDataExample[60661:c07] -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x81765a0 2013-06-16 10:40:48.554 CoreDataExample[60661:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x81765a0' </code></pre> <p>Below the steps that i have followed trying to start the tableview:</p> <ol> <li>Add <em><code>UITableViewDelegate</code></em> and <em><code>UITableViewDataSource</code></em> in my <code>viewController</code>.</li> <li>Insert the <em><code>tableview</code></em> into a view in my <em><code>viewController.xib</code></em>.</li> <li>Create <em><code>datasource</code></em> and <em><code>delegate</code></em> in it files's owner (pressing control key and draging the mouse's arrow from component to file's owner and selecting the option delegate for example).</li> <li>Implement the methods <em><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section</code></em> and <em><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath</code></em> in my <code>viewController.m</code>.</li> </ol> <p>Below the implemetation of two methods:</p> <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 10; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell = nil; static NSString *identifier = @"identifier"; cell = [tableView dequeueReusableCellWithIdentifier:identifier]; if(cell == nil){ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier]; } cell.textLabel.text = @"Olá"; cell.detailTextLabel.text = @"Subtitle" ; [cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton]; return cell; } </code></pre> <p>ViewController.h below:</p> <pre><code>@interface CDEMainViewController : UIViewController &lt;UITableViewDelegate, UITableViewDataSource&gt; - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; @end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload