簡體   English   中英

加載 UITableView 時崩潰

[英]Crash when loading an UITableView

我有一個 UITableView 從三個 NSMutableArrays 加載數據:

  • 一個用於用戶名
  • 一個為實名
  • 一張圖片

當加載少量項目時它工作正常,但是當加載項目(推特關注者)時它崩潰說我:

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

然后我去了它添加對象並刪除代碼的地方,現在奇怪的部分是錯誤仍然存在:我現在不知道在哪里找到:(提前謝謝!我將數據添加到數組的代碼(在 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];
}

但是刪除它仍然會出錯:(

而當 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"
)

您尚未發布有問題的代碼,但異常只是說在您調用insertObject:atIndex:時,您已將nil作為 object 傳遞,這是不允許的。 如果要添加表示no value的值,則必須插入[NSNull null]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM