parse.com - Parse "key cannot be nil" error on [PFObject saveInBackground] (Cocoa) -
i'm trying out parse sdk in existing mac os x application. followed setup steps in parse quickstart guide, including adding import parse library appdelegate .m file , calling:
[parse setapplicationid:kparseapplicationid clientkey:kparseclientkey];
in applicationdidfinishlaunching method. 2 constants use defined in constants file imported.
towards end guide says: "then copy , paste code app, example in viewdidload method (or inside method gets called when run app)"
so imported parse header file main view controller .m file , copied , pasted code viewdidload method:
pfobject *testobject = [pfobject objectwithclassname:@"testobject"]; testobject[@"foo"] = @"bar"; [testobject saveinbackground];
when runs, hit exception message "setobjectforkey: key cannot nil" on last line. not on previous line i'm setting object key. furthermore, if stop on previous line , po testobject, testobject.allkeys, or testobject[@"foo"], show non-nil values key "foo". , still furthermore, if move code end of appdelegate's applicationdidfinishlaunching method, code executes without errors, , testobject shows in parse application dashboard.
can tell me i'm doing wrong? i'd explore further, real blocker me.
here's console log more involved os x app, occurring on [parseobject saveinbackgroundwithblock:]:
2015-06-03 16:55:56.046 testapp [15795:15954566] uncaught exception raised 2015-06-03 16:55:56.046 testapp [15795:15954566] *** setobjectforkey: key cannot nil 2015-06-03 16:55:56.046 testapp [15795:15954566] ( 0 corefoundation 0x00007fff8fb0103c __exceptionpreprocess + 172 1 libobjc.a.dylib 0x00007fff978e476e objc_exception_throw + 43 2 corefoundation 0x00007fff8f9e7c66 -[__nsdictionarym setobject:forkey:] + 1174 3 parseosx 0x000000010011adbb __74-[pfmultiprocessfilelockcontroller beginlockedcontentaccessforfileatpath:]_block_invoke + 129 4 libdispatch.dylib 0x000000010026cd43 _dispatch_client_callout + 8 5 libdispatch.dylib 0x000000010026e0b1 _dispatch_barrier_sync_f_invoke + 348 6 parseosx 0x000000010011ad15 -[pfmultiprocessfilelockcontroller beginlockedcontentaccessforfileatpath:] + 127 7 parseosx 0x00000001000f61ea +[pfobject(private) _objectfromdatafile:error:] + 207 8 parseosx 0x000000010010f231 +[pfuser(private) _getcurrentuserwithoptions:] + 611 9 parseosx 0x00000001000fc4bd -[pfobject(private) saveasync:] + 118 10 parseosx 0x00000001000e1d25 -[pftaskqueue enqueue:] + 188 11 parseosx 0x00000001000ff06b -[pfobject saveinbackground] + 121 12 parseosx 0x00000001000ff270 -[pfobject saveinbackgroundwithblock:] + 49 13 testapp 0x0000000100001827 +[sbtparsetranslation savedbobjecttoparse:] + 183 14 testapp 0x0000000100031fb4 -[swbmainwindowviewcontroller showrecordforitem:] + 3124 15 testapp 0x0000000100031268 -[swbmainwindowviewcontroller showrecordforid:] + 184 16 testapp 0x0000000100031080 -[swbmainwindowviewcontroller finishload] + 448 17 testapp 0x0000000100030eb1 -[swbmainwindowviewcontroller loaddata] + 97 18 testapp 0x0000000100030dd5 -[swbmainwindowviewcontroller viewdidload] + 725
this caused case of confusion on part. work on ios projects, applicationdidfinishlaunching can typically counted on have run before viewcontrollers load. apparently isn't case in os x apps.
in short, calling parseobject save methods before [parse setapplicationid: clientkey] had been called.
Comments
Post a Comment