当我加载数据时,如果没有,我想将tableVIEw.backgroundVIEw的隐藏属性设置为false.这是我到目前为止所拥有的:
func loadData() { let dataSource = tableVIEw.dataSource as! BlockedtableVIEwDataSource let load = dataSource.load(currentUser) # RACSignal load.map { return (func load(user: User) -> RACSignal { return self.getBlocks(user).doNext { self.blocks =as! [AnyObject]).count > 0 }.startWith(true).distinctUntilChanged().setKeyPath("hIDden",onObject: tableVIEw.backgroundVIEw!) load.subscribeError({ error in println(error) },completed: { self.tableVIEw.reloadData() self.refreshControl?.endRefreshing() })}2015-04-28 08:20:02.612 ohio[90547:2154845] *** Terminating app due to uncaught exception 'NSInternalinconsistencyException',reason: 'This query has an outstanding network connection. You have to wait until it's done.'*** First throw call stack:( 0 CoreFoundation 0x000000010b840c65 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010bc5dbb7 objc_exception_throw + 45 2 CoreFoundation 0x000000010b840b9d +[NSException raise:format:] + 205 3 ohio 0x0000000107facb1b -[PFquery checkIfCommandisRunning] + 77 4 ohio 0x0000000107facb71 -[PFquery markAsRunning:] + 46 5 ohio 0x0000000107fad105 -[PFquery _findobjectsAsync:after:] + 234 6 ohio 0x0000000107faf0a0 -[PFquery findobjectsInBackgrounDWithBlock:] + 288 7 ohio 0x0000000107d9532d _TFFE4ohioCSo7PFquery15rac_findobjectsFS0_FT_CSo9RACSignalU_FGSQPSo13RACSubscriber__GSQCSo13RACdisposable_ + 205 8 ohio 0x0000000107d6639e _TTRXFo_oGSQPSo13RACSubscriber___oGSQCSo13RACdisposable__XFo_iGSQPS____iGSQS0___ + 30 9 ohio 0x0000000107d944c1 _TPA__TTRXFo_oGSQPSo13RACSubscriber___oGSQCSo13RACdisposable__XFo_iGSQPS____iGSQS0___ + 81 10 ohio 0x0000000107d663d4 _TTRXFo_iGSQPSo13RACSubscriber___iGSQCSo13RACdisposable__XFo_oGSQPS____oGSQS0___ + 36 11 ohio 0x0000000107d66418 _TTRXFo_oGSQPSo13RACSubscriber___oGSQCSo13RACdisposable__XFdCb_dGSQPS____aGSQS0___ + 56 12 ohio 0x0000000107eeacca __30-[RACDynamicSignal subscribe:]_block_invoke + 74 13 ohio 0x0000000107f35b8e -[RACSubscriptionScheduler schedule:] + 478 14 ohio 0x0000000107eeab9d -[RACDynamicSignal subscribe:] + 765 15 ohio 0x0000000107f28f1d -[RACSignal(Subscription) subscribeNext:error:completed:] + 1133 16 ohio 0x0000000107f004cc __32-[RACSignal(Operations) doNext:]_block_invoke + 396 17 ohio 0x0000000107eeacca __30-[RACDynamicSignal subscribe:]_block_invoke + 74 18 ohio 0x0000000107f35b8e -[RACSubscriptionScheduler schedule:] + 478 19 ohio 0x0000000107eeab9d -[RACDynamicSignal subscribe:] + 765 20 ohio 0x0000000107f2999e -[RACSignal(Subscription) subscribeError:completed:] + 766 21 ohio 0x0000000107dc5fdb _TFC4ohio26BlockedtableVIEwController8loadDatafS0_FCS_4UserT_ + 3083 22 ohio 0x0000000107dc6775 _TFC4ohio26BlockedtableVIEwController11vIEwDIDLoadfS0_FT_T_ + 501 23 ohio 0x0000000107dc7702 _TToFC4ohio26BlockedtableVIEwController11vIEwDIDLoadfS0_FT_T_ + 34 24 UIKit 0x000000010a142210 -[UIVIEwController loadVIEwIfrequired] + 738 25 UIKit 0x000000010a14240e -[UIVIEwController vIEw] + 27 26 UIKit 0x000000010a167297 -[UINavigationController _startCustomTransition:] + 633 27 UIKit 0x000000010a1733bf -[UINavigationController _startDeferredTransitionIfNeeded:] + 386 28 UIKit 0x000000010a173f0e -[UINavigationController __vIEwWillLayoutSubvIEws] + 43 29 UIKit 0x000000010a2be715 -[UILayoutContainerVIEw layoutSubvIEws] + 202 30 UIKit 0x000000011915093e -[UILayoutContainerVIEwAccessibility layoutSubvIEws] + 43 31 UIKit 0x000000010a091a2b -[UIVIEw(CALayerDelegate) layoutSublayersOfLayer:] + 536 32 QuartzCore 0x0000000109d12ec2 -[CALayer layoutSublayers] + 146 33 QuartzCore 0x0000000109d076d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380 34 QuartzCore 0x0000000109d07546 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24 35 QuartzCore 0x0000000109c73886 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242 36 QuartzCore 0x0000000109c74a3a _ZN2CA11Transaction6commitEv + 462 37 QuartzCore 0x0000000109c750eb _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89 38 CoreFoundation 0x000000010b773ca7 __CFRUNLOOP_IS_CALliNG_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23 39 CoreFoundation 0x000000010b773c00 __CFRunLoopDoObservers + 368 40 CoreFoundation 0x000000010b769a33 __CFRunLoopRun + 1123 41 CoreFoundation 0x000000010b769366 CFRunLoopRunspecific + 470 42 GraphiCSServices 0x000000010cfc8a3e GSEventRunModal + 161 43 UIKit 0x000000010a011900 UIApplicationMain + 1282 44 ohio 0x0000000107d86df7 main + 135 45 libdyld.dylib 0x000000010c3c1145 start + 1 46 ??? 0x0000000000000001 0x0 + 1)libc++abi.dylib: terminating with uncaught exception of type NSExceptionas! [Block] }}private func getBlocks(fromUser: User) -> RACSignal { let query = Block.query()! query.whereKey("fromUser",equalTo: fromUser) query.includeKey("toUser") return query.rac_findobjects()}
然而,错误说我需要等待网络请求完成.我正在使用Parse来获取数据,但我认为我的ReactiveCocoa代码没有正确设置并导致此错误.如果我注释掉load.map …部分,表格将按预期填充.
如何以“反应方式”实现这一目标?
更新#1
这是dataSource的加载函数
let load = dataSource.load(currentUser).publish().autoconnect()
更新#2
解决方法 方法rac_findobjects()返回 cold signal.这意味着每次有人订阅此信号时,将重复其副作用(即执行底层网络请求).而且似乎PFquery doesn’t allow to send more than one simultaneous request,因此出现错误消息.在您的情况下,您正在为加载信号进行两次订阅,因为调用setKeyPath也会创建一个.因此,网络请求会被执行两次,从而导致您发布的错误.
如链接的GitHub问题所示,您可以使用RACMulticastConnection确保副作用(网络请求)仅执行一次,无论有多少订阅者.例如:
总结以上是内存溢出为你收集整理的ios – ReactiveCocoa问题全部内容,希望文章能够帮你解决ios – ReactiveCocoa问题所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)