Reputation: 949
elementFetch.predicate = NSPredicate(format: "pageId = %@",(Int32(pagesFromDb.first?.pageId)) !)
var Data = try moc.fetch(elementFetch as! NSFetchRequest<NSFetchRequestResult>) as! [Element]
I tried it with %I
, %d
, and converting to Int
or number, nothing works.
Please suggest how to do this.
Upvotes: 5
Views: 1897
Reputation: 1122
This is because you are using the operator %@
which is for Strings.
For integers use %i
(not %I
) as follows:
elementFetch.predicate = NSPredicate(format: "pageId = %i", pagesFromDb.first?.pageId)
Upvotes: 6