我试图学习如何在iOS / Swift中使用Firestore。我只想尝试推送一些简单的数据,但我总是得到NSInvalidArgumentException
这是我的代码:
import UIKit
import Firebase
class ExercisePreset_ViewController: UIViewController, UITableViewDelegate {
var ref : DocumentReference!
override func viewDidLoad() {
super.viewDidLoad()
ref = Firestore.firestore().collection("test").document("hallo")
let dataToSave : [String: Any] = [
"name" : "hallo",
"type" : "type1"];
ref.setData(dataToSave)
}
这是我的例外:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[FSTImmutableSortedDictionary maybeDocumentDictionary]: unrecognized selector sent to class 0x10a71c258'
*** First throw call stack:
(
0 CoreFoundation 0x000000010d4331e6 __exceptionPreprocess + 294
1 libobjc.A.dylib 0x000000010cac8031 objc_exception_throw + 48
2 CoreFoundation 0x000000010d4b46c4 +[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010d3b5898 ___forwarding___ + 1432
4 CoreFoundation 0x000000010d3b5278 _CF_forwarding_prep_0 + 120
5 TrainingsLog 0x000000010a54fbbe -[FSTLocalDocumentsView documentsForKeys:] + 46
6 TrainingsLog 0x000000010a56a6ed _ZZ39-[FSTLocalStore locallyWriteMutations:]ENK3$_3clEv + 365
7 TrainingsLog 0x000000010a557269 _ZNK20FSTTransactionRunnerclIZ39-[FSTLocalStore locallyWriteMutations:]E3$_3EENSt3__19enable_ifIXntsr3std7is_voidIDTclfp0_EEEE5valueES4_E4typeEN4absl11string_viewET_ + 841
8 TrainingsLog 0x000000010a556e8e -[FSTLocalStore locallyWriteMutations:] + 174
9 TrainingsLog 0x000000010a5dd461 -[FSTSyncEngine writeMutations:completion:] + 161
10 TrainingsLog 0x000000010a51662a __48-[FSTFirestoreClient writeMutations:completion:]_block_invoke + 586
11 TrainingsLog 0x000000010a4f53e4 _ZZ34-[FSTDispatchQueue dispatchAsync:]ENK3$_1clEv + 36
12 TrainingsLog 0x000000010a4f53ad _ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRZ34-[FSTDispatchQueue dispatchAsync:]E3$_1EEEvDpOT_ + 45
13 TrainingsLog 0x000000010a4f5179 _ZNSt3__110__function6__funcIZ34-[FSTDispatchQueue dispatchAsync:]E3$_1NS_9allocatorIS2_EEFvvEEclEv + 41
14 TrainingsLog 0x000000010a4f2b6b _ZNKSt3__18functionIFvvEEclEv + 123
15 TrainingsLog 0x000000010a48e51c _ZN8firebase9firestore4util10AsyncQueue15ExecuteBlockingERKNSt3__18functionIFvvEEE + 476
16 TrainingsLog 0x000000010a490fa7 _ZZN8firebase9firestore4util10AsyncQueue4WrapERKNSt3__18functionIFvvEEEENK3$_0clEv + 39
17 TrainingsLog 0x000000010a490f6d _ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRZN8firebase9firestore4util10AsyncQueue4WrapERKNS_8functionIFvvEEEE3$_0EEEvDpOT_ + 45
18 TrainingsLog 0x000000010a490d29 _ZNSt3__110__function6__funcIZN8firebase9firestore4util10AsyncQueue4WrapERKNS_8functionIFvvEEEE3$_0NS_9allocatorISB_EES7_EclEv + 41
19 TrainingsLog 0x000000010a4f2b6b _ZNKSt3__18functionIFvvEEclEv + 123
20 TrainingsLog 0x000000010a49ea81 _ZZN8firebase9firestore4util8internal13DispatchAsyncEPU28objcproto17OS_dispatch_queue8NSObjectONSt3__18functionIFvvEEEENK3$_0clEPv + 33
21 TrainingsLog 0x000000010a49ea58 _ZZN8firebase9firestore4util8internal13DispatchAsyncEPU28objcproto17OS_dispatch_queue8NSObjectONSt3__18functionIFvvEEEEN3$_08__invokeEPv + 24
22 libdispatch.dylib 0x0000000110ecd848 _dispatch_client_callout + 8
23 libdispatch.dylib 0x0000000110ed5c41 _dispatch_queue_serial_drain + 1305
24 libdispatch.dylib 0x0000000110ed6556 _dispatch_queue_invoke + 328
25 libdispatch.dylib 0x0000000110ed23a0 _dispatch_queue_override_invoke + 726
26 libdispatch.dylib 0x0000000110ed93c8 _dispatch_root_queue_drain + 664
27 libdispatch.dylib 0x0000000110ed90d2 _dispatch_worker_thread3 + 132
28 libsystem_pthread.dylib 0x00000001113f8169 _pthread_wqthread + 1387
29 libsystem_pthread.dylib 0x00000001113f7be9 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)