Grouping a Core Data data result?

后端 未结 3 1935
执笔经年
执笔经年 2020-12-14 13:55

I am prototyping an idea on the iPhone but I am at the SQLite vs CoreData crossroads. The main reason is that I can\'t seem to figure out how to do grouping with core data.

3条回答
  •  难免孤独
    2020-12-14 14:30

    If 'posts' is a NSSet of User, you could get the last post with a predicate:

    NSDate *lastDate = [userInstance valueForKeyPath:@"@max.date"];
    
    NSSet *resultsTemp = [setOfPosts filteredSetUsingPredicate:[NSPredicate predicateWithFormat:@"fecha==%@", lastDate] ];
    

    The resultsTemp set will contain an object of type Post which has the newest date.

提交回复
热议问题