所有
当我的表视图加载时,它会访问多个委托方法。当我配置单元格时,我让它调用这个方法(其中“linkedList”是一个dictionarys数组):
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
VUWIManager *vuwiManager = [VUWIManager sharedVuwiManager];
NSLog(@"%@", [[vuwiManager linkedList]objectAtIndex:indexPath.row]);
NSLog(@"TESTZOMGOFDSOJFDSJFPODJSAPFDS");
cell.textLabel.text = [[vuwiManager linkedList]objectAtIndex:indexPath.row];
return cell;
}
它在cell.textLabel.text = [[vuwiManager linkedList]objectAtIndex:indexPath.row];
行坠毁 - 我知道我在这里做错了但是我不确定它是什么。同样,linkedList是NSDictionarys的NSMutableArray。
编辑:如果我致电cell.textLabel.text = [[vuwiManager linkedList]objectAtIndex:indexPath.row];
,则返回:
调试器中的{
IP = "192.168.17.1";
desc = "description";
}
。我以为我会给出一些格式化细节。
由于
答案 0 :(得分:1)
您正尝试将对象NSDictionary
分配给cell.textLabel.text
,该对象必须通过NSString
。
你想要:
NSString *s = [NSString stringWithFormat:@"%@",
[[vuwiManager linkedList]objectAtIndex:indexPath.row]];
cell.textLabel.text = s;
答案 1 :(得分:1)
将NSString *设置为NSDictionary *可能会在尝试访问字典中未实现的任何字符串方法时导致崩溃。如果您想要记录该字符串,请添加对说明的调用。
cell.textLabel.text = [[[vuwiManager linkedList]objectAtIndex:indexPath.row] description];
答案 2 :(得分:0)
看起来您正在将cell.textLabel.text设置为NSDictionary而不是NSString。如果linkedList是NSDictionaries的NSMutableArray,那么你需要在objectForKey上添加:@“String key”来访问字符串
cell.textLabel.text = [[[vuwiManager linkedList]objectAtIndex:indexPath.row] objectForKey:@"STRING_KEY_HERE"];