Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PFObject does not have a member named 'saveInBackground' in Xcode 6.0.1, Yosemite GM3

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?

like image 887
Gabriel M Sharp Avatar asked Oct 16 '14 18:10

Gabriel M Sharp


3 Answers

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)

like image 129
Greg Fagan Avatar answered Nov 15 '22 12:11

Greg Fagan


If you don't want to mess around with the Parse framework files, you should replace:

score.saveInBackground()

with:

score.saveInBackgroundWithTarget(nil, selector: nil)
like image 44
dstefanis Avatar answered Nov 15 '22 13:11

dstefanis


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.

like image 27
Zorayr Avatar answered Nov 15 '22 12:11

Zorayr