Note that there are some explanatory texts on larger screens.

plurals
  1. POself.tableView insertRowsAtIndexPaths from within tableView delegate
    primarykey
    data
    text
    <p>So I thought I'd have a go at building my own simple app. Please go easy on me I'm new to all this! The idea is this. For iPad have a single view controller with a text box and a text field. Text box takes a title, and text field takes the body of a report. There's a button on the page to submit the report, which bundles the two texts into an object and adds it to a table view within the same view controller. I have set the view controller as a delegate with <code>&lt;UITableViewDelegate, UITableViewDataSource&gt;</code> in my header file. My table view works fine for adding items in the <code>viewDidLoad</code> method. But adding items from the text inputs via a UIButton connected to <code>-(IBAction) addItem</code> falls over with: <code>Property 'tableView' not found on object of type 'ReportsViewController'</code></p> <pre><code>- (IBAction)addReportItem { int newRowIndex = [reports count]; ReportObject *item = [[ReportObject alloc] init]; item.title = @"A new title"; item.reportText = @"A new text"; [reports addObject:item]; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:newRowIndex inSection:0]; NSArray *indexPaths = [NSArray arrayWithObject:indexPath]; [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationAutomatic]; } </code></pre> <p>I understand that I'm trying to call a method within my object but I have other method calls to tableView which work fine. i.e.</p> <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [reports count]; } </code></pre> <p>I thought this was the point of delegation. I know I'm missing something, but as I say I am new to all this and have looked everywhere for an answer before posting. What do I need to do to send my <code>IBAction</code> message to <code>tableView</code>?</p>
    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.
    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