Populating TableView in WatchKit Error

This is how I currently populate my table view in WatchKit:

    - (void)awakeWithContext:(id)context {
    [super awakeWithContext:context];

    // Configure interface objects here.

    menuItems = [[NSMutableArray alloc] initWithObjects:@"Pizza", @"Chicken", @"Bread", nil];

    for (NSString *item in menuItems)
    {
        MenuRowController *menuRow = [myTableView rowControllerAtIndex:[menuItems indexOfObject:item]];
        [menuRow.menuItemLabel setText:item];
    }
}

      

I am getting the following error:

Extension[980:19597] Error - attempt to ask for row 0. Valid range is 0..0
Printing description of item:
Pizza
2015-07-05 01:58:07.284 ScanBarWatch WatchKit Extension[980:19597]    Error - attempt to ask for row 1. Valid range is 0..0
2015-07-05 01:58:14.780 ScanBarWatch WatchKit Extension[980:19597] Error - attempt to ask for row 2. Valid range is 0..0

      

I have tried searching for this error on the internet for several hours to no avail. No one seems to have a solution.

+3


source to share


2 answers


Try to set the number of table rows:



[self.tableView setNumberOfRows:[menuItems count] withRowType:@"MenuRowController"];

      

+6


source


In my case, the error came from a copy and paste problem in IB - the module being used was from a different project.

  • enter image description here


An update to this fixed issue.

enter image description here

+3


source







All Articles