-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gerad Suyderhoud
committed
Sep 14, 2011
1 parent
e0653f9
commit 510fdc1
Showing
18 changed files
with
1,111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,9 @@ | |
.bundle | ||
.monitor | ||
node_modules | ||
|
||
Tractor/build/* | ||
*.pbxuser | ||
*.mode1v3 | ||
xcuserdata | ||
project.xcworkspace/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?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>en</string> | ||
<key>CFBundleExecutable</key> | ||
<string>${EXECUTABLE_NAME}</string> | ||
<key>CFBundleIconFile</key> | ||
<string></string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.fortnightlabs.${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>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>LSApplicationCategoryType</key> | ||
<string>public.app-category.productivity</string> | ||
<key>LSMinimumSystemVersion</key> | ||
<string>${MACOSX_DEPLOYMENT_TARGET}</string> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>Copyright © 2011 Fortnight Labs. All rights reserved.</string> | ||
<key>NSMainNibFile</key> | ||
<string>MainMenu</string> | ||
<key>NSPrincipalClass</key> | ||
<string>NSApplication</string> | ||
<key>LSUIElement</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// | ||
// Prefix header for all source files of the 'Tractor' target in the 'Tractor' project | ||
// | ||
|
||
#ifdef __OBJC__ | ||
#import <Cocoa/Cocoa.h> | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?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>_XCCurrentVersionName</key> | ||
<string>Tractor.xcdatamodel</string> | ||
</dict> | ||
</plist> |
4 changes: 4 additions & 0 deletions
4
Tractor/Tractor/Tractor.xcdatamodeld/Tractor.xcdatamodel/contents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<model name="untitled.xcdatamodel" userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1" systemVersion="11A491" minimumToolsVersion="Automatic" macOSVersion="Automatic" iOSVersion="Automatic"> | ||
<elements/> | ||
</model> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#import <Cocoa/Cocoa.h> | ||
|
||
@interface TractorAppDelegate : NSObject <NSApplicationDelegate> { | ||
NSStatusItem *statusItem; | ||
IBOutlet NSMenu *statusMenu; | ||
NSWindow *window; | ||
NSPersistentStoreCoordinator *__persistentStoreCoordinator; | ||
NSManagedObjectModel *__managedObjectModel; | ||
NSManagedObjectContext *__managedObjectContext; | ||
} | ||
|
||
@property (assign) IBOutlet NSWindow *window; | ||
|
||
@property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator; | ||
@property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel; | ||
@property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext; | ||
|
||
- (IBAction)saveAction:(id)sender; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
#import "TractorAppDelegate.h" | ||
|
||
@implementation TractorAppDelegate | ||
|
||
@synthesize window; | ||
|
||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification | ||
{ | ||
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain]; | ||
[statusItem setImage:[NSImage imageNamed:@"tractor.tiff"]]; | ||
[statusItem setMenu:statusMenu]; | ||
[statusItem setHighlightMode:YES]; | ||
} | ||
|
||
/** | ||
Returns the directory the application uses to store the Core Data store file. This code uses a directory named "Tractor" in the user's Library directory. | ||
*/ | ||
- (NSURL *)applicationFilesDirectory { | ||
|
||
NSFileManager *fileManager = [NSFileManager defaultManager]; | ||
NSURL *libraryURL = [[fileManager URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject]; | ||
return [libraryURL URLByAppendingPathComponent:@"Tractor"]; | ||
} | ||
|
||
/** | ||
Creates if necessary and returns the managed object model for the application. | ||
*/ | ||
- (NSManagedObjectModel *)managedObjectModel { | ||
if (__managedObjectModel) { | ||
return __managedObjectModel; | ||
} | ||
|
||
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Tractor" withExtension:@"momd"]; | ||
__managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; | ||
return __managedObjectModel; | ||
} | ||
|
||
/** | ||
Returns the persistent store coordinator for the application. This implementation creates and return a coordinator, having added the store for the application to it. (The directory for the store is created, if necessary.) | ||
*/ | ||
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator { | ||
if (__persistentStoreCoordinator) { | ||
return __persistentStoreCoordinator; | ||
} | ||
|
||
NSManagedObjectModel *mom = [self managedObjectModel]; | ||
if (!mom) { | ||
NSLog(@"%@:%@ No model to generate a store from", [self class], NSStringFromSelector(_cmd)); | ||
return nil; | ||
} | ||
|
||
NSFileManager *fileManager = [NSFileManager defaultManager]; | ||
NSURL *applicationFilesDirectory = [self applicationFilesDirectory]; | ||
NSError *error = nil; | ||
|
||
NSDictionary *properties = [applicationFilesDirectory resourceValuesForKeys:[NSArray arrayWithObject:NSURLIsDirectoryKey] error:&error]; | ||
|
||
if (!properties) { | ||
BOOL ok = NO; | ||
if ([error code] == NSFileReadNoSuchFileError) { | ||
ok = [fileManager createDirectoryAtPath:[applicationFilesDirectory path] withIntermediateDirectories:YES attributes:nil error:&error]; | ||
} | ||
if (!ok) { | ||
[[NSApplication sharedApplication] presentError:error]; | ||
return nil; | ||
} | ||
} | ||
else { | ||
if ([[properties objectForKey:NSURLIsDirectoryKey] boolValue] != YES) { | ||
// Customize and localize this error. | ||
NSString *failureDescription = [NSString stringWithFormat:@"Expected a folder to store application data, found a file (%@).", [applicationFilesDirectory path]]; | ||
|
||
NSMutableDictionary *dict = [NSMutableDictionary dictionary]; | ||
[dict setValue:failureDescription forKey:NSLocalizedDescriptionKey]; | ||
error = [NSError errorWithDomain:@"YOUR_ERROR_DOMAIN" code:101 userInfo:dict]; | ||
|
||
[[NSApplication sharedApplication] presentError:error]; | ||
return nil; | ||
} | ||
} | ||
|
||
NSURL *url = [applicationFilesDirectory URLByAppendingPathComponent:@"Tractor.storedata"]; | ||
__persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom]; | ||
if (![__persistentStoreCoordinator addPersistentStoreWithType:NSXMLStoreType configuration:nil URL:url options:nil error:&error]) { | ||
[[NSApplication sharedApplication] presentError:error]; | ||
[__persistentStoreCoordinator release], __persistentStoreCoordinator = nil; | ||
return nil; | ||
} | ||
|
||
return __persistentStoreCoordinator; | ||
} | ||
|
||
/** | ||
Returns the managed object context for the application (which is already | ||
bound to the persistent store coordinator for the application.) | ||
*/ | ||
- (NSManagedObjectContext *)managedObjectContext { | ||
if (__managedObjectContext) { | ||
return __managedObjectContext; | ||
} | ||
|
||
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; | ||
if (!coordinator) { | ||
NSMutableDictionary *dict = [NSMutableDictionary dictionary]; | ||
[dict setValue:@"Failed to initialize the store" forKey:NSLocalizedDescriptionKey]; | ||
[dict setValue:@"There was an error building up the data file." forKey:NSLocalizedFailureReasonErrorKey]; | ||
NSError *error = [NSError errorWithDomain:@"YOUR_ERROR_DOMAIN" code:9999 userInfo:dict]; | ||
[[NSApplication sharedApplication] presentError:error]; | ||
return nil; | ||
} | ||
__managedObjectContext = [[NSManagedObjectContext alloc] init]; | ||
[__managedObjectContext setPersistentStoreCoordinator:coordinator]; | ||
|
||
return __managedObjectContext; | ||
} | ||
|
||
/** | ||
Returns the NSUndoManager for the application. In this case, the manager returned is that of the managed object context for the application. | ||
*/ | ||
- (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window { | ||
return [[self managedObjectContext] undoManager]; | ||
} | ||
|
||
/** | ||
Performs the save action for the application, which is to send the save: message to the application's managed object context. Any encountered errors are presented to the user. | ||
*/ | ||
- (IBAction)saveAction:(id)sender { | ||
NSError *error = nil; | ||
|
||
if (![[self managedObjectContext] commitEditing]) { | ||
NSLog(@"%@:%@ unable to commit editing before saving", [self class], NSStringFromSelector(_cmd)); | ||
} | ||
|
||
if (![[self managedObjectContext] save:&error]) { | ||
[[NSApplication sharedApplication] presentError:error]; | ||
} | ||
} | ||
|
||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { | ||
|
||
// Save changes in the application's managed object context before the application terminates. | ||
|
||
if (!__managedObjectContext) { | ||
return NSTerminateNow; | ||
} | ||
|
||
if (![[self managedObjectContext] commitEditing]) { | ||
NSLog(@"%@:%@ unable to commit editing to terminate", [self class], NSStringFromSelector(_cmd)); | ||
return NSTerminateCancel; | ||
} | ||
|
||
if (![[self managedObjectContext] hasChanges]) { | ||
return NSTerminateNow; | ||
} | ||
|
||
NSError *error = nil; | ||
if (![[self managedObjectContext] save:&error]) { | ||
|
||
// Customize this code block to include application-specific recovery steps. | ||
BOOL result = [sender presentError:error]; | ||
if (result) { | ||
return NSTerminateCancel; | ||
} | ||
|
||
NSString *question = NSLocalizedString(@"Could not save changes while quitting. Quit anyway?", @"Quit without saves error question message"); | ||
NSString *info = NSLocalizedString(@"Quitting now will lose any changes you have made since the last successful save", @"Quit without saves error question info"); | ||
NSString *quitButton = NSLocalizedString(@"Quit anyway", @"Quit anyway button title"); | ||
NSString *cancelButton = NSLocalizedString(@"Cancel", @"Cancel button title"); | ||
NSAlert *alert = [[NSAlert alloc] init]; | ||
[alert setMessageText:question]; | ||
[alert setInformativeText:info]; | ||
[alert addButtonWithTitle:quitButton]; | ||
[alert addButtonWithTitle:cancelButton]; | ||
|
||
NSInteger answer = [alert runModal]; | ||
[alert release]; | ||
alert = nil; | ||
|
||
if (answer == NSAlertAlternateReturn) { | ||
return NSTerminateCancel; | ||
} | ||
} | ||
|
||
return NSTerminateNow; | ||
} | ||
|
||
- (void)dealloc | ||
{ | ||
[__managedObjectContext release]; | ||
[__persistentStoreCoordinator release]; | ||
[__managedObjectModel release]; | ||
[super dealloc]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} | ||
{\colortbl;\red255\green255\blue255;} | ||
\paperw9840\paperh8400 | ||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural | ||
|
||
\f0\b\fs24 \cf0 Engineering: | ||
\b0 \ | ||
Some people\ | ||
\ | ||
|
||
\b Human Interface Design: | ||
\b0 \ | ||
Some other people\ | ||
\ | ||
|
||
\b Testing: | ||
\b0 \ | ||
Hopefully not nobody\ | ||
\ | ||
|
||
\b Documentation: | ||
\b0 \ | ||
Whoever\ | ||
\ | ||
|
||
\b With special thanks to: | ||
\b0 \ | ||
Mom\ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* Localized versions of Info.plist keys */ | ||
|
Oops, something went wrong.