拉动刷新崩溃我的应用程序

时间:2015-09-08 05:33:10

标签: ios objective-c xcode macos-carbon

我有一个应用程序,它从共享的Google Api中获取餐馆并将其显示在表格视图中。然后我使用

  

Carbon-kit

用于刷新tableview的内容

    refresh = [[CarbonSwipeRefresh alloc] initWithScrollView:self.tblRest];
    //[refresh setMarginTop:120];
    [refresh setColors:@[[UIColor blueColor], [UIColor redColor], [UIColor orangeColor], [UIColor greenColor]]];
    [self.view addSubview:refresh];

    [refresh addTarget:self action:@selector(pullToRefresh:) forControlEvents:UIControlEventValueChanged];

当我滚动我的表并尝试刷新它时,它给出了以下错误: -

Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 2 beyond bounds for empty array'

请帮我解决这个错误。 提前感谢你。

1 个答案:

答案 0 :(得分:3)

这种情况正在发生,因为您必须在刷新时再次初始化数组。