Let’s say I have the following code
@MainActor
@objc
class MainActorClass: NSObject {
@objc
func myMethod() async throws -> Int {
return 1
}
}
@implementation MainActorClassOwner {
MainActorClass *_mainActorObject;
}
- (instancetype)init {
self = [super init];
if (self) {
_mainActorObject = [[MainActorClass alloc] init];
}
return self;
}
- (void)callMyMethod {
[self->_mainActorObject myMethodWithCompletionHandler:^(NSInteger result, NSError *error) {
NSLog(@"Result: %ld", result);
}];
}
@end
Which executor will run the completion handler? When I tried it, the completion handler was run on the main thread. Is that guaranteed? If so, is it documented?
(CC @Douglas_Gregor who authored SE-0297)