Appending NSDictionary to other NSDictionary

后端 未结 3 640
有刺的猬
有刺的猬 2021-01-31 00:45

I have one NSDictionary and it loads up UITableView. If a user scrolls more and more, I call API and pull new data. This data is again in the form of a

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-31 01:48

    Is your NSDictionary full of other NSDictionaries? It sounds like you would need an NSMutableArray that you could add NSDictionaries to at the end. Assuming you can control the flow of data coming in and wouldn't run the risk of duplicates in your array, you could certainly append the data.

    NSMutableArray *array = [[NSMutableArray alloc] init];
    arrayCount = [array count]; // check the item count
    [array addObject:dictToAppend];
    

    Without seeing how you are implementing it, I can't provide more detailed code examples. Appending items is easy to do, but know it can only be done with mutable versions of Arrays or Dictionaries. Hope this helps a little.

提交回复
热议问题