【问题标题】:UItableview crash at cellForRowAtIndexPath because of my NSMutableArray containing special characters由于我的 NSMutableArray 包含特殊字符,UItableview 在 cellForRowAtIndexPath 崩溃
【发布时间】:2013-05-27 07:20:29
【问题描述】:

我正在从网络服务获取数据并存储在NSMutableArray

app.firstName=[[NSMutableArray alloc]initWithObjects:[[[luckyNumbers    valueForKey:@"findProviders"]valueForKey:@"quotes"]valueForKey:@"firstName"], nil];
NSLog(@"app.first %@",app.firstName);

app.first 
(
    (
    "Tom ",
    shamu,
    Shiva
    )
)
cell.Phone.text=[app.firstName objectAtIndex:indexPath.row];

由于以下未捕获的异常,控制台终止了应用程序:

'NSRangeException',原因:'*** -[__NSArrayM objectAtIndex:]:索引 1 超出范围 [0 .. 0]'

【问题讨论】:

    标签: xcode json uitableview nsmutablearray ios6.1


    【解决方案1】:

    在索引 0 处的 app.firstName 中,您现在有一个数组。您将其分配为显示在字符串中。因此崩溃

    [app.firstName objectAtIndex:indexPath.row]; 返回一个数组而不是字符串。

    试试

    NSArray *tempArray=[app.firstName objectAtIndex:0];
    cell.Phone.text=[tempArray objectAtIndex:indexPath.row];
    

    我认为您需要为此更改编辑数据源方法

    【讨论】:

    • 这就是我所说的你必须编辑数据源方法。将此 temparray 计数返回给 numberOfRowsInSection 方法
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-25
    • 2014-10-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多