Re: Crashing on all relevant exceptions
Re: Crashing on all relevant exceptions
- Subject: Re: Crashing on all relevant exceptions
- From: Shaun Wexler <email@hidden>
- Date: Mon, 7 Aug 2006 20:06:25 -0700
On Aug 7, 2006, at 6:38 PM, Nick Zitzmann wrote:
It's been a while since I tried that, but when I did, it only
worked in threads other than the main thread since NSApplicationMain
() handles exceptions in the main thread. Has this changed at all
lately?
Aaaah, right, you'll need to run the main loop yourself:
#import <Cocoa/Cocoa.h>
static void MyUncaughtExceptionHandler(NSException *exception)
{
// handle the exception
}
int main(int argc, char *argv[])
{
NSSetUncaughtExceptionHandler(MyUncaughtExceptionHandler);
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
NSString *nibName = [infoDict objectForKey:@"NSMainNibFile"];
NSString *className = [infoDict objectForKey:@"NSPrincipalClass"];
Class appClass;
if (className && (appClass = NSClassFromString(className)) = Nil) {
appClass = [NSApplication class];
}
[NSBundle loadNibNamed:nibName owner:[appClass sharedApplication]];
[NSApp finishLaunching];
[pool release];
do {
@try {
[NSApp run];
}
@catch (NSException *exception) {
MyUncaughtExceptionHandler(exception);
}
} while ([NSApp isRunning]);
return 0;
}
--
Shaun Wexler
MacFOH
http://www.macfoh.com
Arguing with an engineer is like wrestling with a pig in mud.
After a while, you realize the pig is enjoying it.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden