Parse is acting very strangely in Yosemite, saveInBackground claims to not be a member of PFObject.
var score = PFObject(className: "score")
score.setObject("Mo", forKey: "name")
score.setObject(1, forKey: "scoreCount")
score.saveInBackground()
Clearly this should work, perhaps it's an issue with Xcode 6.0.1 or Yosemite GM3 (Or a combination). To be clear, using saveInBackgroundWithBlock works fine.
Has anyone else experienced this or a similarly weird bug?
The saveInBackground
method is declared in the header to return a BFTask *
object, which is part of the Bolts framework. Make sure your project is linking the Bolts framework, and then add
#import <Bolts/Bolts.h>
to your bridging header.
This solved a few "missing" APIs in Swift for me (this one, as well as PFAnalytics.trackAppOpenedWithLaunchOptions
mentioned here: Why does my PFAnalytics not have trackAppOpeneWithLaunchOptions function? (IOS SWIFT)
If you don't want to mess around with the Parse framework files, you should replace:
score.saveInBackground()
with:
score.saveInBackgroundWithTarget(nil, selector: nil)
No need for bridging headers since release 1.0. To fix the issue, just add, import Bolts
at the top of your class, below import Parse
:
import Parse
import Bolts
With the added import statement, saveInBackground()
should work as is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With