I have a PFQueryTableViewController subclass which makes a query to a Parse.com table for data with a column named messages, which is of array type.
The query returns the data, except with messages being an empty array (although there is data in the table AND in the messages field).
Below is the query which I create for the Parse data:
- (PFQuery *)queryForTable {
PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
[query whereKey:@"user" equalTo:[PFUser currentUser]];
[query includeKey:@"messages"];
return query;
}
Weird part, once I update the Parse object and save it, reloading the table data fetches the array column's data.
Any idea why it returns an empty array with the initial query?
EDIT:
NSLog() output of the query result (from - (void)objectsDidLoad: ):
objects: (
"<Conversation: 0x7f8590c6b0b0, objectId: 5rO7Y2R5hs, localId: (null)> {\n ACL = \"<PFACL: 0x7f8590e61ec0>\";\n messages = (\n );\n user = \"<PFUser: 0x7f8590d9d260, objectId: M88Oz4annq>\";\n}"
)
Creating the relationship upon button click:
Message *newMessage = [[Message alloc] init];
//... set message properties
[newMessage saveInBackground];
if (!self.parseObject.objectId) {
self.parseObject = [[MyParseObject alloc] init];
[self.parseObject setUser:[User currentUser]];
}
[[self.parseObject messages] addObject:newMessage];
[self.parseObject saveInBackground];
The parseObject class above is what I'm querying.
queryForTablebeing called, so we can be sure the save has finished? - piojoqueryForTableis called automatically by the controller. - kRiZnewMessage. But there are other things that I can think of that could go wrong, but I just don't know enough about what's happening. Also, if we get into tricky stuff about which objects need to be created in which order (and when an object needs to be saved before it can be used), that's shaky ground for me. - piojonewMessageobject gets saved. TheparseObjectobject gets saved with thenewMessageobject's pointer. Just the query does not return it with the rest of the data. - kRiZ