简体   繁体   中英

Crash when loading an UITableView

I have an UITableView which loads data from three 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):

- (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:

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. If you want to add a value denoting no value , you have to insert [NSNull null] instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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