Master data cannot generate where clause for predicate (Swift)

I have a Managed Database Object with NSNumber property (stored as Integer 64). I am trying to get an object using a predicate like this:

let request = NSFetchRequest(entityName: "MyEntity")
request.predicate = NSPredicate(format: "pageId == %@", pageId)

      

and then throws the following runtime error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to generate where clause for predicate (pageId == 22205021) (unknown problem)'

      

where pageId is "22205021" in this case. As far as the suggestions pageId == 22205021

go , it looks ok, which is why I don't understand why it won't work.

Note. I am using Xcode 7 beta 4.

+3


source to share


3 answers


In fact, it turned out to be my mistake - I used a non-existent property for this object in the predicate. "MyEntity" did not contain "pageId" - the best error message would not subside.



+7


source


pageId

cannot be NSObject when in Swift.

Try it NSPredicate(format: "pageId == %d", pageId)

.



This uses an integer for comparison, not NSNumber.

+2


source


The code you posted looks correct to me. If the code works in the previous Xcode and no other changes (other than compliance) I would think it might be a reported bug.

0


source







All Articles