简体   繁体   English

加载 UITableView 时崩溃

[英]Crash when loading an UITableView

I have an UITableView which loads data from three NSMutableArrays:我有一个 UITableView 从三个 NSMutableArrays 加载数据:

  • One for username一个用于用户名
  • One for real name一个为实名
  • One for image一张图片

And when loading a little number of items it works ok, but when loading items (twitter followers) it crash saying me:当加载少量项目时它工作正常,但是当加载项目(推特关注者)时它崩溃说我:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableArray insertObject:atIndex:]: attempt to insert nil object at 2'
*** Call stack at first throw:

Then I went where it adds objects and removed the code, now the weird part is that the error is still there: I don't know where to find now:( thanks in advance! Code where I add data to the array ( on MGTwitterEngine method):然后我去了它添加对象并删除代码的地方,现在奇怪的部分是错误仍然存在:我现在不知道在哪里找到:(提前谢谢!我将数据添加到数组的代码(在 MGTwitterEngine方法):

- (void)userInfoReceived:(NSArray *)userInfo forRequest:(NSString *)connectionIdentifier {
    followers = [[NSMutableArray alloc] init];
    followersname = [[NSMutableArray alloc] init];
    followerspic = [[NSMutableArray alloc] init];

    for(NSDictionary *d in userInfo) {

        NSLog(@"See dictionary: %@", d);
        NSString *user = [d objectForKey:@"screen_name"];
        NSString *realname = [d objectForKey:@"name"];
        NSString *pic = [d objectForKey:@"profile_image_url"];
        [followers addObject:user];
        [followersname addObject:user];
        [followerspic addObject:user];



        NSLog(@"%@", followers);
        NSLog(@"%@", followersname);
        NSLog(@"%@", followerspic);

    }
    [DSBezelActivityView removeViewAnimated:YES];
    [self.tableView reloadData];
}

But removing it still gives error:(但是删除它仍然会出错:(

And when the arrays are like this:而当 arrays 是这样的:

2011-05-28 15:41:41.517 [10854:207] (
    BeybladesOnline,
    zad0xsis,
    wesruca,
    Carlyy6os9n
)
2011-05-28 15:41:41.517 [10854:207] (
    "Beyblades Online",
    "Pablo Merino",
    "Antuan Gualker",
    "Julissa Campbell"
)
2011-05-28 15:41:41.517 [10854:207] (
    "http://a3.twimg.com/profile_images/1235933408/beyblades-thumb_normal.jpg",
    "http://a2.twimg.com/profile_images/1371416207/ProfilePhoto_normal.png",
    "http://a2.twimg.com/profile_images/1257535657/1129844554_b158a92a3a_normal.jpg",
    "http://a1.twimg.com/sticky/default_profile_images/default_profile_0_normal.png"
)

You haven't posted the code in question, but the exception simply says that in your call to insertObject:atIndex: , you have passed nil as object which is not allowed.您尚未发布有问题的代码,但异常只是说在您调用insertObject:atIndex:时,您已将nil作为 object 传递,这是不允许的。 If you want to add a value denoting no value , you have to insert [NSNull null] instead.如果要添加表示no value的值,则必须插入[NSNull null]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM