gpt4 book ai didi

swift 火力基地 : can't create keys with same order exception

转载 作者:行者123 更新时间:2023-11-28 08:29:15 25 4
gpt4 key购买 nike

我正在使用 Firebase 2.5.1 开发一个 macOS Swift 项目。它基本上是一个 CRUD 系统。

我将创建数据路径的方式从 childWithAutoID 更改为自定义字符串,主要是因为我想避免重复条目。

我使用这条新路径(大约 5000 个条目)成功地将所有数据上传到 Firebase。我可以使用以下代码检索它:

//Constants.booksFirebase equals my parent path of Firebase
Constants.booksFirebase.queryOrderedByChild("rentedCount").queryLimitedToLast(10).observeEventType(.Value, withBlock: { snap in

let results = snap.value as? NSDictionary

if let results = results {
self.books = []

for obj in results {
let id = obj.key as! String
self.books.append(id)
}
}
})

但是,如果我查询所有值,我会得到一个 exepection:“无法使用具有相同顺序的键创建 FImmutableSortedDictionary!”。我查询它的方式与示例完全相同以上没有限制:Constants.booksFirebase.queryOrderedByChild("rentedCount").observeEventType(.Value, withBlock:{...}

奇怪的是,我有另一组来自其他路径的数据,Constants.peopleFirebase,它使用与上面相同的逻辑但没有引发异常。

我认为 Firebase 可能会使用相同的 key 上传两个对象,但这只是一个假设。

你知道这个错误是什么意思吗?

我看过这个,但对我没有帮助: Firebase: Can't create FImmutableSortedDictionary with keys with same ordering

谢谢,马塞洛


下面的完整错误:

2016-08-29 21:42:00.846 ProSaber[16218:19613620] An uncaught exception was raised
2016-08-29 21:42:00.846 ProSaber[16218:19613620] Can't create FImmutableSortedDictionary with keys with same ordering!
2016-08-29 21:42:00.846 ProSaber[16218:19613620] (
0 CoreFoundation 0x00007fff94d934f2 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff93ec4f7e objc_exception_throw + 48
2 CoreFoundation 0x00007fff94dfa4bd +[NSException raise:format:] + 205
3 Firebase 0x00000001001e518f __55+[FTreeSortedDictionary fromDictionary:withComparator:]_block_invoke99 + 143
4 CoreFoundation 0x00007fff94d0dc36 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 134
5 CoreFoundation 0x00007fff94d0dac9 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 217
6 Firebase 0x00000001001e4fbc +[FTreeSortedDictionary fromDictionary:withComparator:] + 315
7 Firebase 0x00000001001dd774 +[FImmutableSortedDictionary fromDictionary:withComparator:] + 105
8 Firebase 0x00000001001f67b1 +[FSnapshotUtilities internalNodeFrom:priority:withValidationFrom:atDepth:path:] + 1665
9 Firebase 0x00000001001f60ea +[FSnapshotUtilities nodeFrom:priority:withValidationFrom:atDepth:path:] + 120
10 Firebase 0x00000001001f602e +[FSnapshotUtilities nodeFrom:priority:withValidationFrom:] + 147
11 Firebase 0x00000001001f5f29 +[FSnapshotUtilities nodeFrom:priority:] + 55
12 Firebase 0x00000001002186d1 -[FRepo onDataUpdate:forPath:message:isMerge:tagId:] + 672
13 Firebase 0x000000010022212a -[FPersistentConnection onDataPushWithAction:andBody:] + 591
14 Firebase 0x000000010021eed3 -[FPersistentConnection onDataMessage:withMessage:] + 709
15 Firebase 0x000000010023bd75 -[FConnection onDataMessage:] + 116
16 Firebase 0x000000010023bcac -[FConnection onMessage:withMessage:] + 282
17 Firebase 0x000000010023add0 -[FWebSocketConnection appendFrame:] + 360
18 Firebase 0x000000010023ae8b -[FWebSocketConnection handleIncomingFrame:] + 132
19 Firebase 0x000000010023679f __31-[FSRWebSocket _handleMessage:]_block_invoke + 129
20 libdispatch.dylib 0x0000000100993070 _dispatch_call_block_and_release + 12
21 libdispatch.dylib 0x0000000100985cc5 _dispatch_client_callout + 8
22 libdispatch.dylib 0x000000010098b112 _dispatch_queue_drain + 351
23 libdispatch.dylib 0x0000000100992e24 _dispatch_queue_invoke + 557
24 libdispatch.dylib 0x0000000100989dab _dispatch_root_queue_drain + 1226
25 libdispatch.dylib 0x00000001009898a5 _dispatch_worker_thread3 + 106
26 libsystem_pthread.dylib 0x00000001009e8336 _pthread_wqthread + 1129
27 libsystem_pthread.dylib 0x00000001009e5f91 start_wqthread + 13
)
2016-08-29 21:42:00.847 ProSaber[16218:19613620] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't create FImmutableSortedDictionary with keys with same ordering!'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff94d934f2 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff93ec4f7e objc_exception_throw + 48
2 CoreFoundation 0x00007fff94dfa4bd +[NSException raise:format:] + 205
3 Firebase 0x00000001001e518f __55+[FTreeSortedDictionary fromDictionary:withComparator:]_block_invoke99 + 143
4 CoreFoundation 0x00007fff94d0dc36 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 134
5 CoreFoundation 0x00007fff94d0dac9 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 217
6 Firebase 0x00000001001e4fbc +[FTreeSortedDictionary fromDictionary:withComparator:] + 315
7 Firebase 0x00000001001dd774 +[FImmutableSortedDictionary fromDictionary:withComparator:] + 105
8 Firebase 0x00000001001f67b1 +[FSnapshotUtilities internalNodeFrom:priority:withValidationFrom:atDepth:path:] + 1665
9 Firebase 0x00000001001f60ea +[FSnapshotUtilities nodeFrom:priority:withValidationFrom:atDepth:path:] + 120
10 Firebase 0x00000001001f602e +[FSnapshotUtilities nodeFrom:priority:withValidationFrom:] + 147
11 Firebase 0x00000001001f5f29 +[FSnapshotUtilities nodeFrom:priority:] + 55
12 Firebase 0x00000001002186d1 -[FRepo onDataUpdate:forPath:message:isMerge:tagId:] + 672
13 Firebase 0x000000010022212a -[FPersistentConnection onDataPushWithAction:andBody:] + 591
14 Firebase 0x000000010021eed3 -[FPersistentConnection onDataMessage:withMessage:] + 709
15 Firebase 0x000000010023bd75 -[FConnection onDataMessage:] + 116
16 Firebase 0x000000010023bcac -[FConnection onMessage:withMessage:] + 282
17 Firebase 0x000000010023add0 -[FWebSocketConnection appendFrame:] + 360
18 Firebase 0x000000010023ae8b -[FWebSocketConnection handleIncomingFrame:] + 132
19 Firebase 0x000000010023679f __31-[FSRWebSocket _handleMessage:]_block_invoke + 129
20 libdispatch.dylib 0x0000000100993070 _dispatch_call_block_and_release + 12
21 libdispatch.dylib 0x0000000100985cc5 _dispatch_client_callout + 8
22 libdispatch.dylib 0x000000010098b112 _dispatch_queue_drain + 351
23 libdispatch.dylib 0x0000000100992e24 _dispatch_queue_invoke + 557
24 libdispatch.dylib 0x0000000100989dab _dispatch_root_queue_drain + 1226
25 libdispatch.dylib 0x00000001009898a5 _dispatch_worker_thread3 + 106
26 libsystem_pthread.dylib 0x00000001009e8336 _pthread_wqthread + 1129
27 libsystem_pthread.dylib 0x00000001009e5f91 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException

最佳答案

我不确定这个错误。这听起来很奇怪,但 queryOrderedByChild 旨在与 queryStartingAtValue、queryEndingAtValue 或 queryEqualToValue 一起使用。之后您仍然可以进一步限制查询,但我相信查询需要参数,并且由于您没有提供参数,因此它不知道在哪里查询最多 10 条记录。例如,如果您有 100 条记录,而您的查询仅限于 10 条,那么在没有这些参数的情况下,查询无法知道您真正想要查看 100 条记录中的哪 10 条记录。

关于 swift 火力基地 : can't create keys with same order exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39217248/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com