2

I have 2 classes: User, Books

In User table I have: objectId, AuthorName

In Books table I have: objectId, BookName, authorIDptr

AuthorIDptr is a Pointer to User class

When I run this query:

var bookQuery = PFQuery(className:"Books")
bookQuery.whereKey("authorIDptr", equalTo: PFUser.currentUser().objectId)
bookQuery.includeKey("authorIDptr")

var userQuery = PFUser.query()
userQuery.whereKey("BookName", matchesKey: "Curious George", inQuery: bookQuery)

userQuery.findObjectsInBackgroundWithBlock {....

I get the following error:

Error: Error Domain=Parse Code=102 "The operation couldn’t be completed. (Parse error 102.)" UserInfo=0x7ff2e26f4660 {error=pointer field authorIDptr needs a pointer value, code=102} { code = 102; error = "pointer field authorIDptr needs a pointer value"; }

The Class is populated with data. When i click on the pointer in the Books class, it loads the appropriate User class record.

Can someone help show me what I am doing wrong.

What I want to happen: I want all AuthorNames of a book to show up in a tableview.

Thanks,

Dennis

kRiZ
  • 2,320
  • 4
  • 28
  • 39
dennis
  • 143
  • 1
  • 12

1 Answers1

3

Change this line:

bookQuery.whereKey("authorIDptr", equalTo: PFUser.currentUser().objectId)

into this:

bookQuery.whereKey("authorIDptr", equalTo: PFUser.currentUser())

Pointers in parse are available via object and not objectId. So when you need to query with pointer, you just pass the whole object to the query and the parse will do the rest for you.

kRiZ
  • 2,320
  • 4
  • 28
  • 39
Klemen
  • 2,144
  • 2
  • 23
  • 31
  • Actually, I got it...just update the key with the object...not the objectID...thanks again! – dennis Nov 23 '14 at 18:52