简体   繁体   中英

NSPredicate getting error with CoreData -Swift

I can't find whats wrong in syntax . I cross check with apple documentation as well.

        let predicate = NSPredicate(format: "imageID = %@", imgID);

attached screenshot 截图

You define ImgID as Double , but the predicate format uses the specifier for an object %@ . So, you should either be passing an NSNumber or using %f in the format.

If the ImgID is actually a double then you may have some issue getting an exact match. In this case you should either convert the id to a different data type, or range check (using < and >).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM