ç§ã¯objective-cã®åå¿è ã§ãããããã¯ããªãããå¼ãç¶ãããã½ã¼ã¹ã解æãã¦ãã¾ã 以ä¸ã®ã¨ã©ã¼ãã§ã¾ãã
ãã¿ã¼ã³ï¼
[self performSegueWithIdentifier:@"XXXXXView" sender:nil]; -[UIViewController performSegueWithIdentifier:sender:] must be used from main thread only
ãã®ã¨ã©ã¼ã¯ãUIæä½ï¼ç¹ã«Segueã®å®è¡ï¼ã¯ã¡ã¤ã³ã¹ã¬ããï¼MainThreadï¼ã§è¡ãå¿ è¦ãããã¨ãããã¨ã示ãã¦ãã¾ããiOSã¢ããªã±ã¼ã·ã§ã³ã§ã¯ãUIæä½ã¯å¸¸ã«ã¡ã¤ã³ã¹ã¬ããã§è¡ãããå¿ è¦ãããã¾ãã
ã¨ã©ã¼ã¡ãã»ã¼ã¸ [self performSegueWithIdentifier:@"XXXXXView" sender:nil];
ãã¡ã¤ã³ã¹ã¬ãã以å¤ããå¼ã°ãã¦ããå¯è½æ§ãããã¾ãããããä¿®æ£ããã«ã¯ã次ã®ããã«ãã¦ãã ãã:
ã¡ã¤ã³ã¹ã¬ããã§UIæä½ãè¡ã UIæä½ãè¡ãé¨åãã¡ã¤ã³ã¹ã¬ããã§å®è¡ããããã«ä¿®æ£ãã¾ããObjective-Cã§ã¯ã次ã®ããã«dispatch_asyncã使ã£ã¦è¡ããã¨ãã§ãã¾ã:
dispatch_async(dispatch_get_main_queue(), ^{
[self performSegueWithIdentifier:@"XXXXXView" sender:nil];
});
ãã®ã¨ã©ã¼ã¯ãªãã»ã©ã»ã»ã»ã¨æã£ã
ãã¿ã¼ã³2
以ä¸ã®ã¨ã©ã¼ã¯ã¾ãã§æå³ãããããªã
Main Thread Checker: UI API called on a background thread: -[UIViewController performSegueWithIdentifier:sender:] PID: 12095, TID: 4733842, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0 Backtrace: 4 ApplicationName 0x0000000104971b70 -[XXXXViewController didFinishChkPrice] + 72 5 ApplicationName 0x000000010497b860 -[StoreKitManager finishChkPrice] + 116 6 ApplicationName 0x000000010497a70c -[StoreKitManager productsRequest:didReceiveResponse:] + 376 7 StoreKit 0x00000001baecf3b8 F2CA7CCD-9558-3093-AADB-3353C09DD93C + 115640 8 libdispatch.dylib 0x0000000105958b98 _dispatch_call_block_and_release + 32 9 libdispatch.dylib 0x000000010595a7bc _dispatch_client_callout + 20 10 libdispatch.dylib 0x000000010595d30c _dispatch_queue_override_invoke + 1056 11 libdispatch.dylib 0x000000010596eae4 _dispatch_root_queue_drain + 404 12 libdispatch.dylib 0x000000010596f4d8 _dispatch_worker_thread2 + 188 13 libsystem_pthread.dylib 0x00000001eea138f8 _pthread_wqthread + 228 14 libsystem_pthread.dylib 0x00000001eea100cc start_wqthread + 8 Main Thread Checker: UI API called on a background thread: -[UIViewController performSegueWithIdentifier:sender:] PID: 12095, TID: 4733842, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0 Backtrace: 4 ApplicationName 0x0000000104971b70 -[XXXXXXXXViewController didFinishChkPrice] + 72 5 ApplicationName 0x000000010497b860 -[StoreKitManager finishChkPrice] + 116 6 ApplicationName 0x000000010497a70c -[StoreKitManager productsRequest:didReceiveResponse:] + 376 7 StoreKit 0x00000001baecf3b8 F2CA7CCD-9558-3093-AADB-3353C09DD93C + 115640 8 libdispatch.dylib 0x0000000105958b98 _dispatch_call_block_and_release + 32 9 libdispatch.dylib 0x000000010595a7bc _dispatch_client_callout + 20 10 libdispatch.dylib 0x000000010595d30c _dispatch_queue_override_invoke + 1056 11 libdispatch.dylib 0x000000010596eae4 _dispatch_root_queue_drain + 404 12 libdispatch.dylib 0x000000010596f4d8 _dispatch_worker_thread2 + 188 13 libsystem_pthread.dylib 0x00000001eea138f8 _pthread_wqthread + 228 14 libsystem_pthread.dylib 0x00000001eea100cc start_wqthread + 8 +[UIView setAnimationsEnabled:] being called from a background thread. Performing any operation from a background thread on UIView or a subclass is not supported and may result in unexpected and insidious behavior. trace=( 0 UIKitCore 0x0000000195048740 1741FA37-4E53-371E-8DAE-D611AAB0043D + 19457856 1 libdispatch.dylib 0x000000010595a7bc _dispatch_client_callout + 20 2 libdispatch.dylib 0x000000010595c34c _dispatch_once_callout + 140 3 UIKitCore 0x0000000194dcf454 1741FA37-4E53-371E-8DAE-D611AAB0043D + 16864340 4 UIKitCore 0x0000000194dcf37c 1741FA37-4E53-371E-8DAE-D611AAB0043D + 16864124 5 UIKitCore 0x000000019469d40c 1741FA37-4E53-371E-8DAE-D611AAB0043D + 9319436 6 Project 0x0000000104971b70 -[XXXXViewController didFinishChkPrice] + 72 7 ProjectName 0x000000010497b860 -[StoreKitManager finishChkPrice] + 116 8 Application 0x000000010497a70c -[StoreKitManager productsRequest:didReceiveResponse:] + 376 9 StoreKit 0x00000001baecf3b8 F2CA7CCD-9558-3093-AADB-3353C09DD93C + 115640 10 libdispatch.dylib 0x0000000105958b98 _dispatch_call_block_and_release + 32 11 libdispatch.dylib 0x000000010595a7bc _dispatch_client_callout + 20 12 libdispatch.dylib 0x000000010595d30c _dispatch_queue_override_invoke + 1056 13 libdispatch.dylib 0x000000010596eae4 _dispatch_root_queue_drain + 404 14 libdispatch.dylib 0x000000010596f4d8 _dispatch_worker_thread2 + 188 15 libsystem_pthread.dylib 0x00000001eea138f8 _pthread_wqthread + 228 16 libsystem_pthread.dylib 0x00000001eea100cc start_wqthread + 8 ) Unsupported enumeration of UIWindowScene windows on non-main thread. *** Assertion failure in -[UIApplication _performAfterCATransactionCommitsWithLegacyRunloopObserverBasedTiming:block:], UIApplication.m:3246 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Call must be made on main thread' *** First throw call stack: (0x191bbcf20 0x189a42018 0x1910c3868 0x1940b4d28 0x193ff19e8 0x193ff1518 0x194179830 0x1941786e0 0x1941ce440 0x1946a58f0 0x194dc97c0 0x194dcf45c 0x194dcf37c 0x19469d40c 0x104971b70 0x10497b860 0x10497a70c 0x1baecf3b8 0x105958b98 0x10595a7bc 0x10595d30c 0x10596eae4 0x10596f4d8 0x1eea138f8 0x1eea100cc) libc++abi: terminating due to uncaught exception of type NSException
ã¾ãã§ããããã»ã»ã» ãããããªãã¨ã©ã¼ãã§ãã®ã§ãã
ãã®ã¨ã©ã¼ã®æåã«ãMain Thread Checker: UI API called on a background thread: -[UIViewController performSegueWithIdentifier:sender:]ã ã¨ããã¾ããããã¯ãUI APIãããã¯ã°ã©ã¦ã³ãã¹ã¬ããã§å¼ã°ãã¦ãããã¨ã示ãã¦ãã¾ããã
ã»ã»ã»ï¼
ãããåã
XXXXViewControllerã«ãã
[self performSegueWithIdentifier:@"XXXXXView" sender:nil];
â
dispatch_async(dispatch_get_main_queue(), ^{
[self performSegueWithIdentifier:@"XXXXXView" sender:nil];
});
ã«ä¿®æ£ããããªãã£ã
ã¨ã©ã¼ã調æ»ããçµæ
performSegueWithIdentifier:
ã¡ã½ãããªã©ã®UIæä½ã¯ã
常ã«ã¡ã¤ã³ã¹ã¬ããã§è¡ãããã«ããã®ãæ¨å¥¨ããã¦ãã¾ããiOSã®UIã¯ã¡ã¤ã³ã¹ã¬ããã§ã®ã¿å®å
¨ã«æä½ã§ããããã
ä»ã®ã¹ã¬ããããUIãç´æ¥æä½ããã¨äºæããªãåé¡ãçºçãããã¨ãããã¾ãã
ãããã£ã¦ã以ä¸ã®å ´åã«ã¯ dispatch_async(dispatch_get_main_queue()
ã使ç¨ãã¦ã¡ã¤ã³ã¹ã¬ããã§å®è¡ããããã«ãã¾ã:
éåæå¦çã®å®äºå¾ã«UIãæ´æ°ããå ´å: ããã¯ã°ã©ã¦ã³ãã§ãã¼ã¿ãåå¾ãããã®çµæãUIã«åæ ãããå ´åãéåæå¦çã®å®äºå¾ã«ã¡ã¤ã³ã¹ã¬ããã§UIæä½ãè¡ãå¿ è¦ãããã¾ãã
ã¤ãã³ããã³ãã©å ã§UIãæ´æ°ããå ´å: ãã¿ã³ã®ã¿ãããªã©ã®ã¤ãã³ããã³ãã©å ã§UIæä½ãè¡ãå ´åããã®å¦çãã¡ã¤ã³ã¹ã¬ããã§è¡ãå¿ è¦ãããã¾ãã
ã»ã°ã¨ã®å®è¡ãªã©:
performSegueWithIdentifier:
ããã®ä»ã®UIé·ç§»ãè¡ãã¡ã½ããããã¡ã¤ã³ã¹ã¬ããã§å¼ã³åºãå¿ è¦ãããã¾ãã
é常ã®å ´åãUIé¢é£ã®æä½ã¯ãã¹ã¦ã¡ã¤ã³ã¹ã¬ãã㧠è¡ãããã«ãããã¨ã§ãã¢ããªã®å®å®æ§ã¨ããã©ã¼ãã³ã¹ãä¿ã¤ãã¨ãã§ãã¾ãã
å¤ãã½ã¼ã¹ã¯ãã®ç»é¢é·ç§»ã®é¨åãä¿®æ£ããã®ãå¿ é ã ã