Skip to content

Commit

Permalink
Slightly more interesting Example app.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgenpt committed Dec 31, 2012
1 parent 9b14ecd commit 0435fe0
Show file tree
Hide file tree
Showing 4 changed files with 502 additions and 792 deletions.
2 changes: 0 additions & 2 deletions Examples/DesktopExample/DesktopExample-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>DMAppId</key>
<string>YOUR_APP_ID_HERE</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>
Expand Down
11 changes: 7 additions & 4 deletions Examples/DesktopExample/DesktopExampleAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@

#import <Cocoa/Cocoa.h>

@interface DesktopExampleAppDelegate : NSObject <NSApplicationDelegate> {
@private
NSWindow *window;
}
@interface DesktopExampleAppDelegate : NSObject <NSApplicationDelegate>

@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet NSTextField *nameField;

- (IBAction) simpleButtonPressed:(id)sender;
- (IBAction) nameButtonPressed:(id)sender;
- (IBAction) logTime:(id)sender;

@end

38 changes: 31 additions & 7 deletions Examples/DesktopExample/DesktopExampleAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,43 @@

@implementation DesktopExampleAppDelegate

@synthesize window;
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
{
return YES;
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
DMTracker *tracker = [DMTracker defaultTracker];
[tracker start];

// Delete the #error line and update APP_ID_HERE to make this test application work.
// You can find your application id on app.deskmetrics.com, under "Settings" (bottom left corner) for your app.
#error You need to specify app id in DesktopExample to run it.
[tracker startWithApplicationId:@"APP_ID_HERE"];
}

- (IBAction) simpleButtonPressed:(id)sender
{
[[DMTracker defaultTracker] trackEvent:@"Simple Button"];
}

[tracker trackEvent:@"Startup"];
[tracker trackEvent:@"Startup"
withProperties:@{@"Test": @"Hello!"}];
[tracker trackLog:@"Hello world!"];
- (IBAction) nameButtonPressed:(id)sender
{
NSString *name = self.nameField.stringValue;
if ([name length] > 0) {
[[DMTracker defaultTracker] trackEvent:@"Name Button"
withProperties:@{@"Name": name}];
}
}

- (IBAction) logTime:(id)sender
{
[[DMTracker defaultTracker] trackLog:@"Time is now %@", [NSDate date]];
}

[tracker stop];
- (void)applicationWillTerminate:(NSNotification *)notification
{
[[DMTracker defaultTracker] stop];
}

@end
Loading

0 comments on commit 0435fe0

Please sign in to comment.