解决方法
只需在createdAt上添加降序并获取第一个对象:
PFQuery *query = [PFQuery queryWithClassName:@"YourClassName"]; [query orderByDescending:@"createdAt"]; [query getFirstObjectInBackgroundWithBlock:^(PFObject *object,NSError *error) { // code }];
在斯威夫特:
var query = PFQuery(className: "YourClassName") query.orderByDescending("createdAt") query.getFirstObjectInBackgroundWithBlock {(object: PFObject?,error: NSError?) -> Void in // code }