Table 导致 Apple Watch 崩溃

Table causing crash on Apple Watch

当我尝试使用以下代码启动我的 apple watch 应用程序时,它在日志打印 "produce" 后崩溃(之后没有任何内容)。当我删除代码时,它不会崩溃。我不知道哪里出了问题。

 NSMutableArray *rowTypesList = himo; //himo is a nsmutablearray that contains info from NSXMLParser
        [_table setRowTypes:rowTypesList];
        for (NSInteger i = 0; i < _table.numberOfRows; i++)
        {
            NSDictionary *itemAtIndex =(NSDictionary *)[himo objectAtIndex:i];
            NSObject *row = [_table rowControllerAtIndex:i];
            Cell *importantRow = (Cell *) row;
            [importantRow.label setText:@"hi"];
        }
NSLog(@"produce");

您似乎将要在 table 中显示的数据与行控制器类型混合在一起。如果你只有一个单行控制器类型的单元格,它看起来是你用你的代码做的,你需要以下内容:

[_table setNumberOfRows:[himo count] withRowType:@"theIdentiferYouGaveTheRowControllerInTheStoryboard"];
for (NSInteger i = 0; i < [himo count]; i++) {
    NSDictionary *item = (NSDictionary *)[himo objectAtIndex:i];
    Cell *rowController = [_table rowControllerAtIndex:i];
    [rowController.label setText:@"hi"]; // you probably want to use the data from item here
}