我有错误警告:
我通常在主线程上放置distpach_async来避免这个问题,但是在我的代码中找不到函数 - [UIView retainCount] 。
Main Thread Checker: UI API called on a background thread: -[UIView retainCount]
PID: 71660, TID: 11215956, Thread name: (none), Queue name: com.apple.keyboard.xpc, QoS: 25
Backtrace:
4 liboainject.dylib 0x0000000128d09ca4 _AllocationsObjcLogger + 74
5 liboainject.dylib 0x0000000128d09e0e ___swapMethods_block_invoke_3 + 301
6 libsystem_blocks.dylib 0x0000000110e91bab _Block_object_assign + 207
7 UIKit 0x000000010df0f4f6 __copy_helper_block_.2638 + 31
8 libsystem_blocks.dylib 0x0000000110e918f0 _Block_copy + 113
9 UIKit 0x000000010e996dcc -[UIKeyboardTaskEntry initWithTask:] + 77
10 UIKit 0x000000010e995a2c -[UIKeyboardTaskQueue performTaskOnMainThread:waitUntilDone:] + 119
11 UIKit 0x000000010df0f498 __70-[UIKeyboardImpl syncInputManagerToKeyboardStateWithExecutionContext:]_block_invoke + 90
12 CoreFoundation 0x000000010c4a336c __invoking___ + 140
13 CoreFoundation 0x000000010c4a3240 -[NSInvocation invoke] + 320
14 Foundation 0x000000010b5b85ce __NSXPCCONNECTION_IS_CALLING_OUT_TO_REPLY_BLOCK__ + 17
15 Foundation 0x000000010b7e488a -[NSXPCConnection _decodeAndInvokeReplyBlockWithEvent:sequence:replyInfo:] + 790
16 Foundation 0x000000010b7e89b0 __88-[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:]_block_invoke.346 + 505
17 libxpc.dylib 0x000000011117c61c _xpc_connection_reply_callout + 36
18 libxpc.dylib 0x00000001111719cc _xpc_connection_call_reply_async + 82
19 libdispatch.dylib 0x0000000110da439f _dispatch_client_callout3 + 8
20 libdispatch.dylib 0x0000000110dbc5b7 _dispatch_mach_msg_async_reply_invoke + 369
21 libdispatch.dylib 0x0000000110dac57d _dispatch_queue_serial_drain + 434
22 libdispatch.dylib 0x0000000110dad1ea _dispatch_queue_invoke + 336
23 libdispatch.dylib 0x0000000110db0102 _dispatch_root_queue_drain + 772
24 libdispatch.dylib 0x0000000110dafda0 _dispatch_worker_thread3 + 132
25 libsystem_pthread.dylib 0x000000011126f1ca _pthread_wqthread + 1387
26 libsystem_pthread.dylib 0x000000011126ec4d start_wqthread + 13
2018-01-21 15:51:21.776157+0100 Formbox_Renault_Showroom_Zoe Levallois[71660:11215956] [reports] Main Thread Checker: UI API called on a background thread: -[UIView retainCount]
PID: 71660, TID: 11215956, Thread name: (none), Queue name: com.apple.keyboard.xpc, QoS: 25
Backtrace:
4 liboainject.dylib 0x0000000128d09ca4 _AllocationsObjcLogger + 74
5 liboainject.dylib 0x0000000128d09e0e ___swapMethods_block_invoke_3 + 301
6 libsystem_blocks.dylib 0x0000000110e91bab _Block_object_assign + 207
7 UIKit 0x000000010df0f4f6 __copy_helper_block_.2638 + 31
8 libsystem_blocks.dylib 0x0000000110e918f0 _Block_copy + 113
9 UIKit 0x000000010e996dcc -[UIKeyboardTaskEntry initWithTask:] + 77
10 UIKit 0x000000010e995a2c -[UIKeyboardTaskQueue performTaskOnMainThread:waitUntilDone:] + 119
11 UIKit 0x000000010df0f498 __70-[UIKeyboardImpl syncInputManagerToKeyboardStateWithExecutionContext:]_block_invoke + 90
12 CoreFoundation 0x000000010c4a336c __invoking___ + 140
13 CoreFoundation 0x000000010c4a3240 -[NSInvocation invoke] + 320
14 Foundation 0x000000010b5b85ce __NSXPCCONNECTION_IS_CALLING_OUT_TO_REPLY_BLOCK__ + 17
15 Foundation 0x000000010b7e488a -[NSXPCConnection _decodeAndInvokeReplyBlockWithEvent:sequence:replyInfo:] + 790
16 Foundation 0x000000010b7e89b0 __88-[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:]_block_invoke.346 + 505
17 libxpc.dylib 0x000000011117c61c _xpc_connection_reply_callout + 36
18 libxpc.dylib 0x00000001111719cc _xpc_connection_call_reply_async + 82
19 libdispatch.dylib 0x0000000110da439f _dispatch_client_callout3 + 8
20 libdispatch.dylib 0x0000000110dbc5b7 _dispatch_mach_msg_async_reply_invoke + 369
21 libdispatch.dylib 0x0000000110dac57d _dispatch_queue_serial_drain + 434
22 libdispatch.dylib 0x0000000110dad1ea _dispatch_queue_invoke + 336
23 libdispatch.dylib 0x0000000110db0102 _dispatch_root_queue_drain + 772
24 libdispatch.dylib 0x0000000110dafda0 _dispatch_worker_thread3 + 132
25 libsystem_pthread.dylib 0x000000011126f1ca _pthread_wqthread + 1387
26 libsystem_pthread.dylib 0x000000011126ec4d start_wqthread + 13
你知道在哪里找到它,所以我可以使用:
dispatch_async(dispatch_get_main_queue(), ^{
});
提前致谢。
答案 0 :(得分:3)
您可以与主线程检查程序同时打开一些内存管理调试工具。其中一个内存调试工具是调整保留/释放以进行一些额外的内存管理分析,并且该分析包括对retainCount
的调用,UIView需要从主线程调用。
即。您正在使用两个彼此不兼容的工具。关掉一个。
同样,请通过http://bugreporter.apple.com提交错误。开发人员工具应该阻止您使用此配置,或者应该提供更好的运行时诊断。