How to restructure object of NSDictionaries

后端 未结 2 729
广开言路
广开言路 2020-12-22 13:34

In my debugger this is how my log statement is printing my messages object:

self.messages = (
\"

        
2条回答
  •  Happy的楠姐
    2020-12-22 13:48

    this is a simple NSArray which contains objects of type named lean. you can get the needed object by its index

    UPDATE:

    I can't be sure of course. I have no idea about lean's structure. But most likely it contains field (and I assume it must be a property) named messageBody. If it is really so then you can do the following:

    NSMutableArray* messagesBySenderName = [NSMutableArray new];
    
    for (id lean in objects)
    {
      NSDictionary *messageBody = [lean valueForKeyPath:@"messageBody"];
    
      if ([lean[@"senderId"] isEqualToString:@"Hoy7UjLzOh"])
      {
        [messagesBySenderName addObject:messageBody];
      } 
    }
    

    Again - it is only an assumption. In no case I can guarantee it will work

提交回复
热议问题