Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #5 from mralexgray/master

Mac Example
  • Loading branch information...
commit e1ba7d596c7457519d3e580147b1428164a1de80 2 parents b4bd2ee + 7180b45
@nicklockwood authored
View
24 Examples/MacHRAutoTodoList/AppDelegate.h
@@ -0,0 +1,24 @@
+//
+// AppDelegate.h
+// MacHRAutoTodoList
+//
+// Created by Alex Gray on 11/26/12.
+// Copyright (c) 2012 Alex Gray. All rights reserved.
+//
+
+
+#import "Todos.h"
+
+@interface AppDelegate : NSObject <NSApplicationDelegate>
+
+@property (weak) IBOutlet NSTableView *table;
+@property (nonatomic) TodoList *todos;
+
+- (IBAction) newTodo: (id)sender;
+- (IBAction) loadFromPlist: (id)sender;
+- (IBAction) copyTodo: (id)sender;
+- (IBAction) saveTodos: (id)sender;
+- (IBAction) deleteAll: (id)sender;
+
+@end
+
View
73 Examples/MacHRAutoTodoList/AppDelegate.m
@@ -0,0 +1,73 @@
+//
+// AppDelegate.m
+// MacHRAutoTodoList
+//
+// Created by Alex Gray on 11/26/12.
+// Copyright (c) 2012 Alex Gray. All rights reserved.
+//
+
+#import "AppDelegate.h"
+
+@interface TodoColorCell : NSActionCell
+@end
+@interface TodoPriorityClickCell : NSActionCell
+@end
+
+@implementation AppDelegate
+
+- (TodoList*) todos { return _todos = _todos ?: TodoList.sharedInstance; }
+
+- (IBAction) deleteAll: (id)s { self.todos.items = [NSMutableArray new]; }
+
+- (IBAction) saveTodos: (id)s { [TodoList.sharedInstance save]; }
+
+- (IBAction) copyTodo: (id)s { _table.selectedRowIndexes.count != 0 ? [self.todos copyTodo:self.todos.items[_table.selectedRow]] : nil; }
+
+- (IBAction) newTodo: (id)s { [self.todos newTodo]; }
+
+- (IBAction) loadFromPlist: (id)s
+{
+ self.todos = [TodoList instanceWithContentsOfFile:TodoList.resourceFile];
+ TodoList.sharedInstance = _todos;
+}
+
+-(void)awakeFromNib
+{
+ ((NSTableColumn*)_table.tableColumns[[_table columnWithIdentifier: @"Status"]]).dataCell = TodoColorCell.new;
+ ((NSTableColumn*)_table.tableColumns[[_table columnWithIdentifier: @"Priority"]]).dataCell = TodoPriorityClickCell.new;
+}
+
+@end
+
+/** Custom cells... not directly related to Basemodel, etc... but you can see some ways to access the shared instance, etc */
+
+@implementation TodoPriorityClickCell
+
+- (id) target { return self; }
+
+- (SEL) action { return @selector( tickPriority ); }
+
+- (void) tickPriority
+{
+ NSUInteger val = [self.objectValue unsignedIntegerValue];
+ ((TodoItem*)TodoList.sharedInstance.items[((NSTableView*)self.controlView).selectedRow]).priority = @( val < 8 ? val + 1 : 0 );
+}
+
+- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
+{
+ [NSColor.darkGrayColor set];
+ NSRectFill ( cellFrame );
+ NSString *string = ((NSNumber*)self.objectValue).stringValue;
+ NSDictionary *attrs = @{ NSFontAttributeName : [NSFont fontWithName:@"Lucida Grande Bold" size: cellFrame.size.height - 10], NSForegroundColorAttributeName : NSColor.whiteColor };
+ NSSize stringSize = [string sizeWithAttributes:attrs];
+ [string drawInRect: (NSRect) { NSMidX(cellFrame) - stringSize.width / 2, cellFrame.origin.y + 3, stringSize.width, stringSize.height } withAttributes:attrs];
+}
+
+@end
+
+@implementation TodoColorCell
+
+- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { [(NSColor*)self.objectValue set]; NSRectFill(cellFrame); }
+
+@end
+
View
337 Examples/MacHRAutoTodoList/MacHRAutoTodoList.xcodeproj/project.pbxproj
@@ -0,0 +1,337 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 7B7142EF1663A72200B7661A /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B7142EE1663A72200B7661A /* Cocoa.framework */; };
+ 7B7142FB1663A72200B7661A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B7142FA1663A72200B7661A /* main.m */; };
+ 7B7143021663A72200B7661A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B7143011663A72200B7661A /* AppDelegate.m */; };
+ 7B7143121663A78D00B7661A /* HRCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B71430D1663A78D00B7661A /* HRCoder.m */; };
+ 7B71431A1663A7AD00B7661A /* AutoCoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B7143101663A78D00B7661A /* AutoCoding.m */; };
+ 7B7143201663AB8100B7661A /* TodoItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B71431C1663AB8000B7661A /* TodoItem.m */; };
+ 7B7143221663AB8100B7661A /* TodoList.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B71431E1663AB8000B7661A /* TodoList.m */; };
+ 7B7143241663ACB200B7661A /* TodoList.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7B7143231663ACB200B7661A /* TodoList.plist */; };
+ 7B71432A1663AFB100B7661A /* BaseModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B7143171663A79800B7661A /* BaseModel.m */; };
+ 7B71432D1663AFE300B7661A /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7B71432B1663AFE300B7661A /* MainMenu.xib */; };
+ 7B71435616641ABE00B7661A /* thatch.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 7B71435516641ABE00B7661A /* thatch.jpg */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 7B7142EA1663A72200B7661A /* MacHRAutoTodoList.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MacHRAutoTodoList.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 7B7142EE1663A72200B7661A /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
+ 7B7142F11663A72200B7661A /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
+ 7B7142F21663A72200B7661A /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
+ 7B7142F31663A72200B7661A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ 7B7142F61663A72200B7661A /* MacHRAutoTodoList-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "MacHRAutoTodoList-Info.plist"; sourceTree = "<group>"; };
+ 7B7142FA1663A72200B7661A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ 7B7142FC1663A72200B7661A /* MacHRAutoTodoList-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MacHRAutoTodoList-Prefix.pch"; sourceTree = "<group>"; };
+ 7B7143001663A72200B7661A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.objj.h; path = AppDelegate.h; sourceTree = "<group>"; };
+ 7B7143011663A72200B7661A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
+ 7B71430C1663A78D00B7661A /* HRCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.objj.h; path = HRCoder.h; sourceTree = "<group>"; };
+ 7B71430D1663A78D00B7661A /* HRCoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HRCoder.m; sourceTree = "<group>"; };
+ 7B71430F1663A78D00B7661A /* AutoCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.objj.h; path = AutoCoding.h; sourceTree = "<group>"; };
+ 7B7143101663A78D00B7661A /* AutoCoding.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AutoCoding.m; sourceTree = "<group>"; };
+ 7B7143161663A79800B7661A /* BaseModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.objj.h; path = BaseModel.h; sourceTree = "<group>"; };
+ 7B7143171663A79800B7661A /* BaseModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BaseModel.m; sourceTree = "<group>"; };
+ 7B71431B1663AB8000B7661A /* Todos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.objj.h; path = Todos.h; sourceTree = "<group>"; };
+ 7B71431C1663AB8000B7661A /* TodoItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TodoItem.m; sourceTree = "<group>"; };
+ 7B71431E1663AB8000B7661A /* TodoList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TodoList.m; sourceTree = "<group>"; };
+ 7B7143231663ACB200B7661A /* TodoList.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = TodoList.plist; sourceTree = SOURCE_ROOT; };
+ 7B71432C1663AFE300B7661A /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; };
+ 7B71435516641ABE00B7661A /* thatch.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = thatch.jpg; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 7B7142E71663A72200B7661A /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 7B7142EF1663A72200B7661A /* Cocoa.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 7B7142DF1663A72200B7661A = {
+ isa = PBXGroup;
+ children = (
+ 7B71430B1663A78D00B7661A /* HRCoder */,
+ 7B71430E1663A78D00B7661A /* AutoCoding */,
+ 7B7143151663A79800B7661A /* BaseModel */,
+ 7B7142F51663A72200B7661A /* Supporting Files */,
+ 7B7143001663A72200B7661A /* AppDelegate.h */,
+ 7B7143011663A72200B7661A /* AppDelegate.m */,
+ 7B71431B1663AB8000B7661A /* Todos.h */,
+ 7B71431C1663AB8000B7661A /* TodoItem.m */,
+ 7B71431E1663AB8000B7661A /* TodoList.m */,
+ 7B7143231663ACB200B7661A /* TodoList.plist */,
+ 7B7142ED1663A72200B7661A /* Frameworks */,
+ 7B7142EB1663A72200B7661A /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ 7B7142EB1663A72200B7661A /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 7B7142EA1663A72200B7661A /* MacHRAutoTodoList.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 7B7142ED1663A72200B7661A /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 7B7142EE1663A72200B7661A /* Cocoa.framework */,
+ 7B7142F01663A72200B7661A /* Other Frameworks */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ 7B7142F01663A72200B7661A /* Other Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 7B7142F11663A72200B7661A /* AppKit.framework */,
+ 7B7142F21663A72200B7661A /* CoreData.framework */,
+ 7B7142F31663A72200B7661A /* Foundation.framework */,
+ );
+ name = "Other Frameworks";
+ sourceTree = "<group>";
+ };
+ 7B7142F51663A72200B7661A /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ 7B71435516641ABE00B7661A /* thatch.jpg */,
+ 7B71432B1663AFE300B7661A /* MainMenu.xib */,
+ 7B7142F61663A72200B7661A /* MacHRAutoTodoList-Info.plist */,
+ 7B7142FA1663A72200B7661A /* main.m */,
+ 7B7142FC1663A72200B7661A /* MacHRAutoTodoList-Prefix.pch */,
+ );
+ name = "Supporting Files";
+ path = MacHRAutoTodoList;
+ sourceTree = "<group>";
+ };
+ 7B71430B1663A78D00B7661A /* HRCoder */ = {
+ isa = PBXGroup;
+ children = (
+ 7B71430C1663A78D00B7661A /* HRCoder.h */,
+ 7B71430D1663A78D00B7661A /* HRCoder.m */,
+ );
+ name = HRCoder;
+ path = ../HRTodoList/HRCoder;
+ sourceTree = "<group>";
+ };
+ 7B71430E1663A78D00B7661A /* AutoCoding */ = {
+ isa = PBXGroup;
+ children = (
+ 7B71430F1663A78D00B7661A /* AutoCoding.h */,
+ 7B7143101663A78D00B7661A /* AutoCoding.m */,
+ );
+ name = AutoCoding;
+ path = ../AutoTodoList/AutoCoding;
+ sourceTree = "<group>";
+ };
+ 7B7143151663A79800B7661A /* BaseModel */ = {
+ isa = PBXGroup;
+ children = (
+ 7B7143161663A79800B7661A /* BaseModel.h */,
+ 7B7143171663A79800B7661A /* BaseModel.m */,
+ );
+ name = BaseModel;
+ path = ../../BaseModel;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 7B7142E91663A72200B7661A /* MacHRAutoTodoList */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 7B7143081663A72200B7661A /* Build configuration list for PBXNativeTarget "MacHRAutoTodoList" */;
+ buildPhases = (
+ 7B7142E61663A72200B7661A /* Sources */,
+ 7B7142E71663A72200B7661A /* Frameworks */,
+ 7B7142E81663A72200B7661A /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = MacHRAutoTodoList;
+ productName = MacHRAutoTodoList;
+ productReference = 7B7142EA1663A72200B7661A /* MacHRAutoTodoList.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 7B7142E11663A72200B7661A /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0450;
+ ORGANIZATIONNAME = "Alex Gray";
+ };
+ buildConfigurationList = 7B7142E41663A72200B7661A /* Build configuration list for PBXProject "MacHRAutoTodoList" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = 7B7142DF1663A72200B7661A;
+ productRefGroup = 7B7142EB1663A72200B7661A /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 7B7142E91663A72200B7661A /* MacHRAutoTodoList */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 7B7142E81663A72200B7661A /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 7B7143241663ACB200B7661A /* TodoList.plist in Resources */,
+ 7B71432D1663AFE300B7661A /* MainMenu.xib in Resources */,
+ 7B71435616641ABE00B7661A /* thatch.jpg in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 7B7142E61663A72200B7661A /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 7B7142FB1663A72200B7661A /* main.m in Sources */,
+ 7B7143021663A72200B7661A /* AppDelegate.m in Sources */,
+ 7B7143121663A78D00B7661A /* HRCoder.m in Sources */,
+ 7B71431A1663A7AD00B7661A /* AutoCoding.m in Sources */,
+ 7B7143201663AB8100B7661A /* TodoItem.m in Sources */,
+ 7B7143221663AB8100B7661A /* TodoList.m in Sources */,
+ 7B71432A1663AFB100B7661A /* BaseModel.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ 7B71432B1663AFE300B7661A /* MainMenu.xib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 7B71432C1663AFE300B7661A /* en */,
+ );
+ name = MainMenu.xib;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ 7B7143061663A72200B7661A /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.8;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = macosx;
+ };
+ name = Debug;
+ };
+ 7B7143071663A72200B7661A /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.8;
+ SDKROOT = macosx;
+ };
+ name = Release;
+ };
+ 7B7143091663A72200B7661A /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "MacHRAutoTodoList/MacHRAutoTodoList-Prefix.pch";
+ INFOPLIST_FILE = "MacHRAutoTodoList/MacHRAutoTodoList-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ 7B71430A1663A72200B7661A /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "MacHRAutoTodoList/MacHRAutoTodoList-Prefix.pch";
+ INFOPLIST_FILE = "MacHRAutoTodoList/MacHRAutoTodoList-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 7B7142E41663A72200B7661A /* Build configuration list for PBXProject "MacHRAutoTodoList" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 7B7143061663A72200B7661A /* Debug */,
+ 7B7143071663A72200B7661A /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 7B7143081663A72200B7661A /* Build configuration list for PBXNativeTarget "MacHRAutoTodoList" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 7B7143091663A72200B7661A /* Debug */,
+ 7B71430A1663A72200B7661A /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 7B7142E11663A72200B7661A /* Project object */;
+}
View
34 Examples/MacHRAutoTodoList/MacHRAutoTodoList/MacHRAutoTodoList-Info.plist
@@ -0,0 +1,34 @@
+<?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.github.mralexgray.${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>LSMinimumSystemVersion</key>
+ <string>${MACOSX_DEPLOYMENT_TARGET}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>Copyright © 2012 Alex Gray. All rights reserved.</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
View
10 Examples/MacHRAutoTodoList/MacHRAutoTodoList/MacHRAutoTodoList-Prefix.pch
@@ -0,0 +1,10 @@
+//
+// Prefix header for all source files of the 'MacHRAutoTodoList' target in the 'MacHRAutoTodoList' project
+//
+
+#ifdef __OBJC__
+
+ #import <Foundation/Foundation.h>
+ #import <Cocoa/Cocoa.h>
+
+#endif
View
2  Examples/MacHRAutoTodoList/MacHRAutoTodoList/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
View
3,988 Examples/MacHRAutoTodoList/MacHRAutoTodoList/en.lproj/MainMenu.xib
3,988 additions, 0 deletions not shown
View
14 Examples/MacHRAutoTodoList/MacHRAutoTodoList/main.m
@@ -0,0 +1,14 @@
+//
+// main.m
+// MacHRAutoTodoList
+//
+// Created by Alex Gray on 11/26/12.
+// Copyright (c) 2012 Alex Gray. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+int main(int argc, char *argv[])
+{
+ return NSApplicationMain(argc, (const char **)argv);
+}
View
BIN  Examples/MacHRAutoTodoList/MacHRAutoTodoList/thatch.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
66 Examples/MacHRAutoTodoList/TodoItem.m
@@ -0,0 +1,66 @@
+
+// TodoItem.m
+// TodoList
+
+// Created by Alex Gray on 11/26/12.
+// Part of BaseModel by Nick Lockwood.
+
+#import "Todos.h"
+
+@interface TodoItem ()
+@property (readwrite) NSDate *created;
+@end
+
+@implementation TodoItem
+
+- (void) setUp
+{
+ _checked = NO;
+ _created = [NSDate date];
+ _label = [NSString stringWithFormat:@"New todo, created:%@", [_created descriptionWithLocale:nil]];
+ _priority = @1;
+}
+
+#pragma - UNUSED INIT METHODS /* ironically, neither of these init methods is actually called... but this is how you do it */
+
++ (instancetype)instanceWithLabel:(NSString *)label // sort of like a designated initializer, except you dont need to redo any other init's...
+{ // just make one with whatever poperties you want to set in one step in your actual init method.
+ TodoItem *instance = [self instance];
+ instance.label = label;
+ return instance;
+}
+
++ (instancetype)instanceWithObject:(id)object
+{
+ TodoItem *instance = [self instance]; // generic init
+ for (NSString *key in [object allKeys]) // iterate through dictionary keys and setValue if our instance responds
+ if ([instance respondsToSelector:NSSelectorFromString([NSString stringWithFormat:@"set%@", [key uppercaseString]])])
+ [instance setValue:((NSDictionary*)object)[key] forKey:key];
+ return instance;
+}
+
+#pragma readonly properties
+
+- (NSColor*) color
+{
+ return self.checked ? [NSColor colorWithPatternImage:[NSImage imageNamed:@"thatch"]] :
+ self.priority.intValue == 1 ? [NSColor colorWithCalibratedRed:0.843 green:0.000 blue:0.119 alpha:1.000] :
+ self.priority.intValue == 2 ? [NSColor colorWithCalibratedRed:1.000 green:0.861 blue:0.225 alpha:1.000] :
+ self.priority.intValue == 3 ? [NSColor colorWithCalibratedRed:0.986 green:0.484 blue:0.032 alpha:1.000] :
+ self.priority.intValue == 4 ? [NSColor colorWithCalibratedRed:0.739 green:0.900 blue:0.000 alpha:1.000] :
+ self.priority.intValue == 5 ? [NSColor colorWithCalibratedRed:0.369 green:0.630 blue:0.589 alpha:1.000] :
+ self.priority.intValue == 6 ? [NSColor colorWithCalibratedRed:0.253 green:0.478 blue:0.761 alpha:1.000] :
+ self.priority.intValue == 7 ? [NSColor colorWithCalibratedRed:0.630 green:0.336 blue:0.576 alpha:1.000] :
+ [NSColor colorWithCalibratedRed:0.883 green:0.254 blue:0.700 alpha:1.000];
+}
+
+#pragma KVO junk
+
++ (NSSet*) keyPathsForValuesAffectingColor { return [NSSet setWithArray:@[@"checked", @"priority"]]; }
+
+
+/* note: we've not implemented the NSCoding methods or initWithString/Dictionary, etc
+ because the HRCoder and AutoCoding libraries take care of this for us */
+
+
+@end
View
37 Examples/MacHRAutoTodoList/TodoList.m
@@ -0,0 +1,37 @@
+
+// TodoList.m
+// TodoListExample
+
+// Created by Alex Gray on 11/26/12.
+// Part of BaseModel by Nick Lockwood.
+
+
+#import "Todos.h"
+
+@implementation TodoList
+
+/* note: we've not implemented the NSCoding methods or setWithArray/Dictionary, etc
+ because the HRCoder and AutoCoding libraries take care of this for us */
+
+- (TodoItem*) newTodo
+{
+ TodoItem *newOne = TodoItem.instance;
+ [self insertObject:newOne inItemsAtIndex:self.items.count]; // KVO Array insertion trigger.
+ return newOne;
+}
+- (TodoItem*) copyTodo: (TodoItem*)todo;
+{
+ TodoItem *newOne = todo.copy;
+ [self insertObject:newOne inItemsAtIndex:self.items.count];
+ return newOne;
+}
+
+- (NSUInteger)countOfItems { return self.items.count; }
+
+- (id)objectInItemsAtIndex:(NSUInteger)index { return self.items[index]; }
+
+- (void)removeObjectFromItemsAtIndex:(NSUInteger)index { [self.items removeObjectAtIndex:index]; }
+
+- (void)insertObject:(TodoItem*)todo inItemsAtIndex:(NSUInteger)index { [self.items insertObject:todo atIndex:index]; }
+
+@end
View
65 Examples/MacHRAutoTodoList/TodoList.plist
@@ -0,0 +1,65 @@
+<?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>items</key>
+ <array>
+ <dict>
+ <key>$class</key>
+ <string>TodoItem</string>
+ <key>label</key>
+ <string>Pay the apple tax.</string>
+ <key>checked</key>
+ <false/>
+ <key>priority</key>
+ <integer>5</integer>
+ </dict>
+ <dict>
+ <key>$class</key>
+ <string>TodoItem</string>
+ <key>label</key>
+ <string>Do washing</string>
+ <key>priority</key>
+ <integer>3</integer>
+ </dict>
+ <dict>
+ <key>$class</key>
+ <string>TodoItem</string>
+ <key>label</key>
+ <string>Mow lawn</string>
+ <key>checked</key>
+ <false/>
+ <key>priority</key>
+ <integer>6</integer>
+ </dict>
+ <dict>
+ <key>$class</key>
+ <string>TodoItem</string>
+ <key>label</key>
+ <string>Write an open source library</string>
+ <key>priority</key>
+ <integer>4</integer>
+ </dict>
+ <dict>
+ <key>$class</key>
+ <string>TodoItem</string>
+ <key>label</key>
+ <string>Feed the cat</string>
+ <key>priority</key>
+ <integer>2</integer>
+ </dict>
+ <dict>
+ <key>$class</key>
+ <string>TodoItem</string>
+ <key>label</key>
+ <string>Make peace with oneself.</string>
+ <key>checked</key>
+ <false/>
+ <key>priority</key>
+ <integer>1</integer>
+ </dict>
+ </array>
+ <key>$class</key>
+ <string>TodoList</string>
+</dict>
+</plist>
View
33 Examples/MacHRAutoTodoList/Todos.h
@@ -0,0 +1,33 @@
+
+// TodoItem.h
+// TodoList
+
+// Created by Alex Gray on 11/26/12.
+// Part of BaseModel by Nick Lockwood.
+
+#import "BaseModel.h"
+
+@interface TodoItem : BaseModel
+
+@property (readonly) NSColor *color;
+@property (nonatomic, strong) NSString *label;
+@property (nonatomic, strong) NSNumber *priority;
+@property (nonatomic) BOOL checked;
+
+@end
+
+@interface TodoList : BaseModel
+
+@property (nonatomic, strong) NSMutableArray *items;
+
+- (TodoItem*) newTodo;
+- (TodoItem*) copyTodo: (TodoItem*)todo;
+
+// Subclass specific KVO Compliant "items" accessors to trigger NSArrayController updates on inserts / removals.
+- (NSUInteger) countOfItems;
+- (id) objectInItemsAtIndex: (NSUInteger) index;
+- (void) removeObjectFromItemsAtIndex: (NSUInteger) index;
+- (void) insertObject: (TodoItem*) todo
+ inItemsAtIndex: (NSUInteger) index;
+
+@end
Please sign in to comment.
Something went wrong with that request. Please try again.