請查看我的代碼,我正在使用它在我的表視圖添加運行時添加動態單元格。在選擇我的表格視圖時,我稱這種方法。問題在表視圖中添加動態單元格?
- (void) allServersFound
{
// called from delegate when bonjourservices has listings of machines:
NSArray *newPosts = [[NSArray alloc]initWithObjects:@"A", nil]; // NSArray of machine names;
NSMutableArray *tempArray = [[NSMutableArray alloc] initWithObjects: @"A",@"B",@"C",@"D", nil];
int i = 0;
for (NSArray *count in newPosts)
{
[tempArray addObject:[NSIndexPath indexPathForRow:i++ inSection:0]];
}
[[self tblHome] beginUpdates];
[[self tblHome] insertRowsAtIndexPaths:tempArray withRowAnimation:UITableViewRowAnimationNone];
[[self tblHome] endUpdates];
[tempArray release];
}
但是,這給了我以下在運行時異常: *終止應用程序由於未捕獲的異常 'NSInvalidArgumentException',原因是:「 - [NSIndexPath _fastCStringContents:]:無法識別的選擇發送到實例0x4e0e130