简体   繁体   中英

'PFObject values may not have class: NSConcreteValue'

App keeps crashing on this Method - trying to simply pin a Parse object to the local data store as outlined in the docs Parse docs :

func saveToBackground(title:String, description:String, coords:CLLocationCoordinate2D, image:UIImage, objectId:String, dateFound:String){

    let imageData = image.jpeg(.low)
    let imageFile = PFFile(name: "image.png", data: imageData!)


    let foundObject = PFObject(className: "FoundObjects")
    foundObject["title"] = title
    foundObject["description"] = description
    foundObject["coordinates"] = coords
    foundObject["image"] = imageFile
    foundObject["objectId"] = objectId
    foundObject["dateFound"] = dateFound
    foundObject.pinInBackground()

}

error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'PFObject values may not have class: NSConcreteValue'

Any ideas anyone?

At least one of your values is an NSConcreteValue class, which can't be stored on a PFObject. Figure out which line is causing the issue by setting a breakpoint and stepping through, and make sure to cast that value to the expected class. Or you could cast all of these to their expected class, cover your bases.

Edit: As pointed out by MartynE23, the issue was actually the CLLocationCoordinate2D, which must be converted to a PFGeoPoint to add to a Parse Object

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