The toUser pointer field requires a Parse.com pointer value
I have a Parse.com class called Messages where I have 3 columns:
- fromUser - Pointer<_User>
- toUser - Pointer<_User>
- image - File
In my UITableView, I am trying to restore all objects in the message class where toUser is equal to PUUser currentUser. I am getting this error when I make a request:
UserInfo=0x1702e3580 {code=102, temporary=0, error=pointer field toUser needs a pointer value, originalError=Error Domain=NSURLErrorDomain Code=-1011 "The operation couldn’t be completed. (NSURLErrorDomain error -1011.)"} {
code = 102;
error = "pointer field toUser needs a pointer value";
originalError = "Error Domain=NSURLErrorDomain Code=-1011 \"The operation couldn\U2019t be completed. (NSURLErrorDomain error -1011.)\"";
temporary = 0;
}
This is how I make the request:
- (void)retriveMessages {
PFQuery *query = [PFQuery queryWithClassName:@"Messages"];
[query whereKey:@"toUser" equalTo:[[PFUser currentUser] objectId]];
[query orderByDescending:@"createdAt"];
query.limit = 1000;
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (error) {
NSLog(@"Error: %@ %@", error, error.userInfo);
} else {
// Found messages!
self.messages = objects;
[self.tableView reloadData];
NSLog(@"%@", objects);
}
}];
}
+3
tracifycray
source
to share
1 answer
It is a common mistake to confuse objects with pointers. Change the value of equalTo: test to:
[query whereKey:@"toUser" equalTo:[PFUser currentUser]];
EDIT In JS / Cloud code, it works the same:
var someParseObject = // probably from another query
query.equalTo("somePointerAttribute", someParseObject);
// in cloud functions with a request parameter, the requesting user is available
query.equalTo("pointerToAUserAttribute", request.user);
+3
danh
source
to share