UITableView崩溃与逗号和空格在字符串的UITableViewCell



如果我在NSArray中有一个类似" Help, Support and More "的字符串,这是UITableView的内容,它在启动时崩溃。如果我删除" , "后面的空白,则没有问题。

有什么解决办法吗?

这个<<p> strong>崩溃:
cell.textLabel.text = @"Help, Support and More";
这个<<p> strong> :
cell.textLabel.text = @"Help,Support and More";

下面是更多的代码:

- (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];
        //cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    // Configure the cell.
    NSLog(@"%@", [[sportstypes objectAtIndex: [indexPath row]] title]);
    cell.textLabel.text = @"Tes t:, ,,,,,";
    //cell.textLabel.text = @"Blubber";
    return cell;
}

修复:Xcode 4.6.2应用程序每秒钟运行崩溃感谢ice_2

如果你得到错误线程1:信号SIGABRT每秒钟启动。打开"产品->方案->编辑方案"菜单,选择"运行YouAppName"。app的左侧,点击"信息"。然后在调试器字段中选择GDB而不是LLDB。

似乎是OS X 10.8.4和LLDB的组合。正如kenster所说,切换到GDB会使问题消失。

我认为你做错了什么。因为你的代码是正确的,在你的代码没有问题,第二件事,你可以把任何特殊字符在双引号" 。它不会产生任何问题。

这可能是由于内存问题。确保数组没有在任何地方被释放或移除。启用僵尸并运行它,以便您可以在调试器控制台中接收一些日志

问题可能在这一行

NSLog(@"%@", [[sportstypes objectAtIndex: [indexPath row]] title]);

注释并执行,看看会发生什么

最新更新