I have a unique msgid for each ChatData object.
@interface ChatData : RLMObject
@property NSInteger msgid;
....
@end
But each time I create a new object I have to query all objects and get the last msgid.
RLMArray *all = [[ChatData allObjects] arraySortedByProperty:@"msgid" ascending:YES];
ChatData *last = [all lastObject];
ChatData *newData = [[ChataData alloc]init];
newData.msgid = last.msgid+1;
Is there an efficient way to replace this implementation?