【发布时间】:2014-02-07 17:33:59
【问题描述】:
我正在使用 sqlite 中的语句从表中选择特定对象:
NSString *statment = [NSString stringWithFormat:@"SELECT * FROM %@ ORDER BY %@ DESC LIMIT 1", TRAP_TABLE, DISTANCE_TO_CLOSE_POINT];
我想使用核心数据做同样的事情。
我应该如何混合 NSPredicate 和 NSSortDescriptor 才能做到这一点?
编辑: 这是我做的,还没试过:
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:DISTANCE_TO_CLOSE_POINT ascending:NO selector:@selector(localizedCompare:)];
【问题讨论】:
标签: ios objective-c sqlite core-data