Skip to content

Instantly share code, notes, and snippets.

@pookjw
Created April 7, 2025 15:30
Show Gist options
  • Save pookjw/6fa8809965db1228981f30911c2dc2bc to your computer and use it in GitHub Desktop.
Save pookjw/6fa8809965db1228981f30911c2dc2bc to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
@interface Error : NSError
@end
@implementation Error
+ (BOOL)occurError:(NSError **)error {
*error = [[Error alloc] initWithDomain:NSCocoaErrorDomain code:0 userInfo:nil];
return NO;
}
- (void)dealloc {
NSLog(@"%s", __func__);
}
@end
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSError * _Nullable error = nil;
for (NSUInteger i = 0; i < 100; i++) @autoreleasepool {
[Error occurError:&error];
}
NSLog(@"%@", error);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment