Skip to content

Instantly share code, notes, and snippets.

@hhyyy9
Created September 29, 2012 01:28
Show Gist options
  • Save hhyyy9/3802852 to your computer and use it in GitHub Desktop.
Save hhyyy9/3802852 to your computer and use it in GitHub Desktop.
当程序崩溃(Crash)时发出通知
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//BSCrashNotifier is a bundle that allows you to be notified when your app is crashing.
NSBundle* bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"BSCrashNotifier" ofType:@"bundle"]];
Class crashNotifierClass = [bundle principalClass];
if (crashNotifierClass)
{
[crashNotifierClass onCrashSend:@selector(weCrashed:) to:self];
}
else
{
NSLog(@"couldn't load bundle");
}
//and implement the notification method like:
- (void)weCrashed:(int)signalNumber
{
NSLog(@"we crashed: %i",signalNumber);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment