Environment:
Xcode Version: 16.0 (latest stable release) iOS Version: 18.3.1 Devices: physical devices Configuration: Main Thread Checker enabled (Edit Scheme > Run > Diagnostics)
Issue Description
When the Main Thread Checker is enabled, methods defined in a UIViewController category (e.g., supportedInterfaceOrientations) fail to execute, whereas the subclass implementation of the same method works as expected. This conflicts with the normal behavior where both implementations should be called.
Steps to Reproduce
1、Declare a category method in UIViewController+Extend.m:
// UIViewController+Extend.m
@implementation UIViewController (Extend)
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
NSLog(@"category supportedInterfaceOrientations hit");
return UIInterfaceOrientationMaskAll;
}
@end
2、Override the same method in a subclass ,call super methed(ViewController.m):
// ViewController.m
@implementation ViewController
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
NSLog(@"subclass called supportedInterfaceOrientations called");
return [super supportedInterfaceOrientations]; // Expected to call the category implementation
}
@end
3、Expected Behavior (Main Thread Checker disabled):
subclass called supportedInterfaceOrientations called
category supportedInterfaceOrientations hit
4、Actual Behavior (Main Thread Checker enabled):
subclass called supportedInterfaceOrientations called
// category supportedInterfaceOrientations hit
Requested Resolution
Please investigate:
1、Why Main Thread Checker disrupts category method invocation.
2、Whether this is a broader issue affecting other UIKit categories.
UIViewController
already has a supportedInterfaceOrientations
method. You can’t add a second implementation using a category. That’s just not supported and will result in undefined behaviour.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"