由于我创建了一个readJson方法,因此出现此错误:
y = as.matrix(model.matrix(lm(y ~ as.factor(y))))
我知道问题是什么,阅读看起来我必须使用This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.
Stack:(
0 CoreFoundation 0x0000000100731d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001024d8deb objc_exception_throw + 48
2 CoreFoundation 0x0000000100731cbd +[NSException raise:format:] + 205
3 Foundation 0x0000000100cadb6b _AssertAutolayoutOnMainThreadOnly + 79
4 Foundation 0x0000000100b0d357 -[NSISEngine withBehaviors:performModifications:] + 31
5 UIKit 0x0000000101850adb -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 58
6 UIKit 0x0000000101850477 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 646
7 UIKit 0x0000000101850ae4 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 67
8 UIKit 0x00000001018501ac -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 242
9 UIKit 0x0000000101005538 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 113
10 UIKit 0x0000000101005461 -[UIView(Hierarchy) _postMovedFromSuperview:] + 544
11 UIKit 0x000000010101326c -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1967
12 MacCRM 0x0000000100471a40 _TFE6MacCRMCSo6UIViewP33_0AB6F1737B613FE8A7F8E017F6C0671E9showToastfT5toastS0_8durationSd8positionPs9AnyObject__T_ + 1296
13 MacCRM 0x000000010046e8bc _TFE6MacCRMCSo6UIView9makeToastfT7messageSS8durationSd8positionPs9AnyObject__T_ + 428
14 MacCRM 0x0000000100471ee3 _TToFE6MacCRMCSo6UIView9makeToastfT7messageSS8durationSd8positionPs9AnyObject__T_ + 99
15 MacCRM 0x000000010046e688 _TFE6MacCRMCSo6UIView9makeToastfT7messageSS_T_ + 136
16 MacCRM 0x000000010046e6f8 _TToFE6MacCRMCSo6UIView9makeToastfT7messageSS_T_ + 72
17 MacCRM 0x000000010049c176 _TFFFC6MacCRM7Ajustes7guardarFPs9AnyObject_T_U_FT_T_U_FTGSqCSo6NSData_GSqCSo13NSURLResponse_GSqCSo7NSError__T_ + 7462
18 MacCRM 0x000000010048c0a7 _TTRXFo_oGSqCSo6NSData_oGSqCSo13NSURLResponse_oGSqCSo7NSError__dT__XFdCb_dGSqS__dGSqS0__dGSqS1___dT__ + 103
19 CFNetwork 0x0000000103a17b49 __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 19
20 CFNetwork 0x0000000103a2a0f2 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 302
21 Foundation 0x0000000100bac630 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
22 Foundation 0x0000000100ae7805 -[NSBlockOperation main] + 101
23 Foundation 0x0000000100aca725 -[__NSOperationInternal _start:] + 646
24 Foundation 0x0000000100aca336 __NSOQSchedule_f + 194
25 libdispatch.dylib 0x0000000102f6e3eb _dispatch_client_callout + 8
26 libdispatch.dylib 0x0000000102f5482c _dispatch_queue_drain + 2215
27 libdispatch.dylib 0x0000000102f53d4d _dispatch_queue_invoke + 601
28 libdispatch.dylib 0x0000000102f56996 _dispatch_root_queue_drain + 1420
29 libdispatch.dylib 0x0000000102f56405 _dispatch_worker_thread3 + 111
30 libsystem_pthread.dylib 0x00000001032c24de _pthread_wqthread + 1129
31 libsystem_pthread.dylib 0x00000001032c0341 start_wqthread + 13
我在里面调用我的方法,但仍然有问题。有些想法?
由于
编辑:已解决
问题是我的吐司图书馆。
答案 0 :(得分:0)
您的代码不正确。您正在使用:
dispatch_async(dispatch_get_main_queue()) {...
在启动dataTask之前,dataTask将异步运行,因为dataTask将异步工作,闭包将在后台线程中执行。
您可以通过删除以下行来修复它:
dispatch_async(dispatch_get_main_queue()) {
从哪里开始,然后在完成块中添加它,如果你有这样的话:
...{ data, response, error in
dispatch_async(dispatch_get_main_queue()) {
它会正常工作。
但是你应该只在计算操作完成时调用主线程,这样硬件才能由后台线程完成。