Permalink
Browse files

Initial commit.

  • Loading branch information...
kstenerud committed Nov 22, 2010
1 parent 8a728a7 commit b550d870908a80819c16575a77a1e34190fd6ec4
View
@@ -0,0 +1,10 @@
+build
+*.DS_Store
+*.mode1v3
+*.pbxuser
+*.bak
+.~*
+._*
+Thumbs.db
+project.pbxproj.mergesave
+doxygen.config
@@ -0,0 +1,21 @@
+//
+// CrashManagerDemoAppDelegate.h
+// CrashManager
+//
+// Created by Karl Stenerud on 10-09-13.
+//
+
+#import <UIKit/UIKit.h>
+
+@class CrashManagerDemoViewController;
+
+@interface CrashManagerDemoAppDelegate : NSObject <UIApplicationDelegate> {
+ UIWindow *window;
+ CrashManagerDemoViewController *viewController;
+}
+
+@property (nonatomic, retain) IBOutlet UIWindow *window;
+@property (nonatomic, retain) IBOutlet CrashManagerDemoViewController *viewController;
+
+@end
+
@@ -0,0 +1,57 @@
+//
+// CrashManagerDemoAppDelegate.m
+// CrashManager
+//
+// Created by Karl Stenerud on 10-09-13.
+//
+
+#import "CrashManagerDemoAppDelegate.h"
+#import "CrashManagerDemoViewController.h"
+#import "CrashManager.h"
+#import "StackTracer.h"
+
+@implementation CrashManagerDemoAppDelegate
+
+@synthesize window;
+@synthesize viewController;
+
+
+#pragma mark -
+#pragma mark Application lifecycle
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ [window addSubview:viewController.view];
+ [window makeKeyAndVisible];
+
+ // Install Crash Manager
+ [[CrashManager sharedInstance] manageCrashes];
+ [[CrashManager sharedInstance] setCrashDelegate:self selector:@selector(notifyException:stackTrace:)];
+
+ return YES;
+}
+
+- (void)dealloc
+{
+ [viewController release];
+ [window release];
+ [super dealloc];
+}
+
+- (void) notifyException:(NSException*) exception stackTrace:(NSArray*) stackTrace
+{
+ // Oh no! We crashed!
+ // Time to output some stuff to the console.
+
+ // Note: Any EXC_BAD_ACCESS crashes (such as accessing a deallocated object) will
+ // cause the app to close stdout, so you won't see this trace in such a case.
+
+ NSLog(@"Exception:\n%@\n", exception);
+
+ NSLog(@"Full Trace:\n%@\n", [[StackTracer sharedInstance] printableTrace:stackTrace]);
+
+ NSArray* intelligentTrace = [[StackTracer sharedInstance] intelligentTrace:stackTrace];
+ NSLog(@"Condensed Intelligent Trace:\n%@", [[StackTracer sharedInstance] condensedPrintableTrace:intelligentTrace]);
+}
+
+@end
@@ -0,0 +1,23 @@
+//
+// CrashManagerDemoViewController.h
+// CrashManager
+//
+// Created by Karl Stenerud on 10-09-13.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface CrashManagerDemoViewController : UIViewController
+{
+ NSString* deallocatedString;
+ int zeroDivisor;
+}
+
+- (IBAction) onCrash_divByZero;
+- (IBAction) onCrash_deallocatedObject;
+- (IBAction) onCrash_unimplementedSelector;
+- (IBAction) onCrash_outOfBounds;
+
+- (IBAction) onMail;
+@end
+
@@ -0,0 +1,61 @@
+//
+// CrashManagerDemoViewController.m
+// CrashManager
+//
+// Created by Karl Stenerud on 10-09-13.
+//
+
+#import "CrashManagerDemoViewController.h"
+#import "CrashManager.h"
+#import "Mailer.h"
+
+@implementation CrashManagerDemoViewController
+
+- (void) doDivisionByZero
+{
+ NSLog(@"%d", 10 / zeroDivisor);
+}
+
+- (IBAction) onCrash_divByZero
+{
+ // Note: A raised signal destroys the topmost entry on the stack, so the
+ // stack trace will only show onCrash_divByZero, and not doDivisionByZero.
+ [self doDivisionByZero];
+}
+
+- (IBAction) onCrash_deallocatedObject
+{
+ // Note: EXC_BAD_ACCESS errors tend to cause the app to close stdout,
+ // which means you won't see the trace on your console.
+ // It is, however, stored to the error log file.
+ NSObject* object = [[NSObject alloc] init];
+ [object release];
+ NSLog(@"%@", object);
+}
+
+- (IBAction) onCrash_outOfBounds
+{
+ NSArray* array = [NSArray arrayWithObject:[[[NSObject alloc] init] autorelease]];
+ NSLog(@"%@", [array objectAtIndex:100]);
+}
+
+- (IBAction) onCrash_unimplementedSelector
+{
+ id notAViewController = [NSData data];
+ [notAViewController presentModalViewController:nil animated:NO];
+}
+
+- (IBAction) onMail
+{
+ NSString* errorReport = [CrashManager sharedInstance].errorReport;
+ if(nil != errorReport)
+ {
+ [[Mailer sharedInstance] sendMailTo:nil
+ subject:@"Error Report"
+ message:errorReport
+ isHtml:NO];
+ }
+}
+
+
+@end
View
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>NSMainNibFile</key>
+ <string>MainWindow</string>
+</dict>
+</plist>
Oops, something went wrong.

0 comments on commit b550d87

Please sign in to comment.