【发布时间】:2014-12-02 20:23:31
【问题描述】:
每个 ChatData 对象都有一个唯一的 msgid。
@interface ChatData : RLMObject
@property NSInteger msgid;
....
@end
但是每次我创建一个新对象时,我都必须查询所有对象并获取最后一个 msgid。
RLMArray *all = [[ChatData allObjects] arraySortedByProperty:@"msgid" ascending:YES];
ChatData *last = [all lastObject];
ChatData *newData = [[ChataData alloc]init];
newData.msgid = last.msgid+1;
有没有一种有效的方法来替换这个实现?
【问题讨论】: