Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 get 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 tried looking up this error online for a couple of hours but to no avail. No one seems to have a solution.

like image 255
Faisal Syed Avatar asked Dec 25 '22 17:12

Faisal Syed


1 Answers

Try to set the number of rows of the table:

[self.tableView setNumberOfRows:[menuItems count] withRowType:@"MenuRowController"];
like image 56
fredpi Avatar answered Dec 28 '22 09:12

fredpi