4

I am currently using the latest version of Parse 1.14.2 and Bolts 1.8.4.Parse is implemented correctly and I have been using it for a long time now. The problem I'm facing now is when I try to use Parse's local datastore. I have the following code in my AppDelegate.swift:

Parse.enableLocalDatastore()
                Parse.setApplicationId("ID",
                clientKey: "Client_Key")

I have the following code to create and save a string named firstName in a class named contact:

let contact = PFObject(className: "contact")
                        contact["firstName"] = "Jack"
                        contact.pinInBackground()

Here is the code to retrieve objects from the created class:

                            let query = PFQuery(className: "contact")
                        query.fromLocalDatastore()
                        query.getFirstObjectInBackgroundWithBlock({ (object, error) -> Void in
                            if error == nil {
                                if let contact = object {
                                    print(contact.objectForKey("firstName"))

                                }
                            }
                        })

I have added libsqlite3.dylib to my project. My app doesn't crash when I run this code but it simply gives me the following message when I try to retrieve objects:

    2016-08-29 11:31:38.049 App_Demo[14436:3504319] [Bolts] Warning: `BFTask` caught an exception in the continuation block. 
This behavior is discouraged and will be removed in a future release. 
Caught Exception: Method requires Pinning enabled.

Can anyone help me to work around this issue? I am guessing the issue is that this version of Bolts cannot pin Parse objects in the background and I need to work my way around this bug. Any help would be appreciated as I have been stuck at this for a while and can't find too much info online.

Edited: I have tried downgrading Bolts, but then Parse downgrades with it in Cocoapod and it causes errors in Xcode.

rici
  • 234,347
  • 28
  • 237
  • 341
bbkrz
  • 423
  • 1
  • 8
  • 16
  • Did you find a solution? I am facing the same issue – kashif789us Oct 04 '16 at 16:04
  • No, I tried everything and I gave up on this method. I am not an expert in programming and I didn't find a solution but I assume that since Parse is shutting down, they didn't actually update the local datastore functions for a swift 2+ in their new SDKs. I also had some issues when trying to implement FB login using Parse. Using core data in Xcode was way easier for me in this case (Had to learn core data from scratch, but worth it). – bbkrz Oct 08 '16 at 12:15

1 Answers1

0

it's not objectforkey. You need to call object["UsedName"] "UsedName" being the key. Hope that helps.

user2867432
  • 382
  • 4
  • 14