Using the parse local data source
viewController1 - pinning the data to the local store.
let number = PFObject(className: "userNo")
number["phoneNumber"] = phoneNumber.text
number.pin()
viewController 2 - attempting to retrieve the data
var query = PFQuery(className:"userNo")
query.fromLocalDatastore()
query.getObjectInBackgroundWithId(string()) { //this line may be the issue?
(objects: PFObject!, error: NSError!) -> Void in
if error == nil {
var numberX = (PFObject()["phoneNumber"] as String)
self.phoneNumber.text = numberX
} else {
println("Error retreiving")
}
I am saving the users phone number in viewController1, via the parse local store method (*.pin()). This works fine.
In viewController2 I am attempting to show the user the locally stored data in a static cell 'detail'.
I have managed to make this work using PFUser.query and PFUser.Current user methods, but I don't think this is the right method to do this in. The parse doc actually state that we should retrieve data via PFObject, however how can we even do this without an ObjectId!?
viewController1
let number = PFUser.currentUser()
number["phoneNumber"] = phoneNumber.text
number.pin()
self.performSegueWithIdentifier("phoneDone", sender: self)
and then on viewController2
var query = PFUser.query()
query.fromLocalDatastore()
phoneNumber.text = (PFUser.currentUser()["phoneNumber"] as String)
If someone has a better solution, I would like to hear it. Thanks
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.