解析本地数据存储:默认ACL崩溃

时间:2014-12-20 12:46:06

标签: ios parse-platform

在iOS应用中启用本地数据存储后,默认ACL已开始崩溃:

    Parse.setApplicationId(kParseApplicationId, clientKey: kParseClientId)
    Parse.enableLocalDatastore() // Although docs say this call should be before setApplicationId call(), doing it causes exception

    PFUser.enableAutomaticUser()
    PFUser.currentUser().saveEventually()

    var defaultACL = PFACL()
    defaultACL.setPublicReadAccess(true)
    PFACL.setDefaultACL(defaultACL, withAccessForCurrentUser:true) // This line causes crash!

任何想法可能会发生什么?

崩溃日志附于下方:

2014-12-20 16:42:07.762 inventoryapp[75258:1857255] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'cannot setReadAccess for unsaved user'
*** First throw call stack:
(
0   CoreFoundation                      0x000000010c8b9f35 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x000000010cf4ebb7 objc_exception_throw + 45
2   CoreFoundation                      0x000000010c8b9e6d +[NSException raise:format:] + 205
3   inventoryapp                        0x0000000109418fee -[PFACL setReadAccess:forUser:] + 160
4   inventoryapp                        0x00000001094195f9 +[PFACL defaultACL] + 279
5   inventoryapp                        0x000000010943a553 -[PFObject(Private) setDefaultValues] + 50
6   inventoryapp                        0x000000010942f6b1 -[PFObject(Private) init] + 686
7   inventoryapp                        0x0000000109204421 _TFC12inventoryapp6ClientcfMS0_FT_S0_ + 49
8   inventoryapp                        0x0000000109204462 _TFC12inventoryapp6ClientCfMS0_FT_S0_ + 50
9   inventoryapp                        0x000000010921372f _TFC12inventoryapp23AddEditClientControllercfMS0_FT5coderCSo7NSCoder_S0_ + 111
10  inventoryapp                        0x000000010921385d _TToFC12inventoryapp23AddEditClientControllercfMS0_FT5coderCSo7NSCoder_S0_ + 45
11  UIKit                               0x000000010b5d09dd -[UIClassSwapper initWithCoder:] + 205
12  UIKit                               0x000000010b7356c6 UINibDecoderDecodeObjectForValue + 705
13  UIKit                               0x000000010b7353fc -[UINibDecoder decodeObjectForKey:] + 276
14  UIKit                               0x000000010b5d05d6 -[UIRuntimeConnection initWithCoder:] + 153
15  UIKit                               0x000000010b5d0c69 -[UIRuntimeEventConnection initWithCoder:] + 45
16  UIKit                               0x000000010b7356c6 UINibDecoderDecodeObjectForValue + 705
17  UIKit                               0x000000010b735895 UINibDecoderDecodeObjectForValue + 1168
18  UIKit                               0x000000010b7353fc -[UINibDecoder decodeObjectForKey:] + 276
19  UIKit                               0x000000010b5cfa79 -[UINib instantiateWithOwner:options:] + 990
20  UIKit                               0x000000010b859572 -[UIStoryboard instantiateViewControllerWithIdentifier:] + 181
21  UIKit                               0x000000010b85c6cc -[UIStoryboardSegueTemplate _perform:] + 71
22  inventoryapp                        0x0000000109205330 _TFC12inventoryapp20ViewClientController14viewWillAppearfS0_FSbT_ + 1264
23  inventoryapp                        0x00000001092053e1 _TToFC12inventoryapp20ViewClientController14viewWillAppearfS0_FSbT_ + 49
24  UIKit                               0x000000010b433821 -[UIViewController _setViewAppearState:isAnimating:] + 487
25  UIKit                               0x000000010b453605 -[UINavigationController _startCustomTransition:] + 887
26  UIKit                               0x000000010b45f3fe -[UINavigationController _startDeferredTransitionIfNeeded:] + 386
27  UIKit                               0x000000010b45ff47 -[UINavigationController __viewWillLayoutSubviews] + 43
28  UIKit                               0x000000010b5a5509 -[UILayoutContainerView layoutSubviews] + 202
29  UIKit                               0x000000010b383973 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
30  QuartzCore                          0x000000010b017de8 -[CALayer layoutSublayers] + 150     31  QuartzCore                          0x000000010b00ca0e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
32  QuartzCore                          0x000000010b00c87e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
33  QuartzCore                          0x000000010af7a63e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
34  QuartzCore                          0x000000010af7b74a _ZN2CA11Transaction6commitEv + 390
35  QuartzCore                          0x000000010af7bdb5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
36  CoreFoundation                      0x000000010c7eedc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
37  CoreFoundation                      0x000000010c7eed20 __CFRunLoopDoObservers + 368
38  CoreFoundation                      0x000000010c7e4b53 __CFRunLoopRun + 1123
39  CoreFoundation                      0x000000010c7e4486 CFRunLoopRunSpecific + 470
40  GraphicsServices                    0x000000010ef789f0 GSEventRunModal + 161
41  UIKit                               0x000000010b30a420 UIApplicationMain + 1282
42  inventoryapp                        0x00000001091d3dee top_level_code + 78
43  inventoryapp                        0x00000001091d3e2a main + 42
44  libdyld.dylib                       0x000000010d728145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

禁用defaultACL代码后,它现在启动正常,但没有与PFUser有关系的对象被保存,我收到以下错误

2014-12-20 17:31:39.377 inventoryapp[76964:1882821] [Error]: {"__type":"Pointer","className":"_User","localId":"local_b570eef90326ed75"} is not a valid Pointer (Code: 106, Version: 1.6.1)
2014-12-20 17:31:39.382 inventoryapp[76964:1882805] [Error]: Failed to run command eventually with error: Error Domain=Parse Code=106 "The operation couldn’t be completed. (Parse error 106.)" UserInfo=0x7f8cb8c9e190 {error={"__type":"Pointer","className":"_User","localId":"local_b570eef90326ed75"} is not a valid Pointer, code=106}

我正在使用Parse SDK 1.6.1

2 个答案:

答案 0 :(得分:0)

解析文档说要在setApplicationId之前放置enableLocalDatastore。试一试。

答案 1 :(得分:0)

尝试新的补丁(1.6.1)并查看它是否适合您。

新修补程序还会强制您在初始化之前启用本地数据存储(现在它应该正常工作!)。