├── .travis.yml ├── BaseModel.podspec.json ├── BaseModel ├── BaseModel.h └── BaseModel.m ├── Examples ├── BasicTodoList │ ├── Classes │ │ ├── NewItemViewController.h │ │ ├── NewItemViewController.m │ │ ├── NewItemViewController.xib │ │ ├── TodoItem.h │ │ ├── TodoItem.m │ │ ├── TodoList.h │ │ ├── TodoList.m │ │ ├── TodoListAppDelegate.h │ │ ├── TodoListAppDelegate.m │ │ ├── TodoListViewController.h │ │ └── TodoListViewController.m │ ├── Default-568h@2x.png │ ├── MainWindow.xib │ ├── TodoList-Info.plist │ ├── TodoList.plist │ ├── TodoList.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ ├── TodoListViewController.xib │ ├── TodoList_Prefix.pch │ └── main.m ├── CryptoTodoList │ ├── Classes │ │ ├── NewItemViewController.h │ │ ├── NewItemViewController.m │ │ ├── NewItemViewController.xib │ │ ├── TodoItem.h │ │ ├── TodoItem.m │ │ ├── TodoList.h │ │ ├── TodoList.m │ │ ├── TodoListAppDelegate.h │ │ ├── TodoListAppDelegate.m │ │ ├── TodoListViewController.h │ │ └── TodoListViewController.m │ ├── CryptoTodoList-Info.plist │ ├── CryptoTodoList.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ ├── CryptoTodoList_Prefix.pch │ ├── Default-568h@2x.png │ ├── MainWindow.xib │ ├── TodoList.plist │ ├── TodoListViewController.xib │ └── main.m ├── FCTodoList │ ├── Classes │ │ ├── NewItemViewController.h │ │ ├── NewItemViewController.m │ │ ├── NewItemViewController.xib │ │ ├── TodoItem.h │ │ ├── TodoItem.m │ │ ├── TodoList.h │ │ ├── TodoList.m │ │ ├── TodoListAppDelegate.h │ │ ├── TodoListAppDelegate.m │ │ ├── TodoListViewController.h │ │ └── TodoListViewController.m │ ├── Default-568h@2x.png │ ├── FCTodoList-Info.plist │ ├── FCTodoList.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── HRTodoList.xcscheme │ ├── FCTodoList_Prefix.pch │ ├── MainWindow.xib │ ├── TodoListViewController.xib │ └── main.m ├── HRTodoList │ ├── Classes │ │ ├── NewItemViewController.h │ │ ├── NewItemViewController.m │ │ ├── NewItemViewController.xib │ │ ├── TodoItem.h │ │ ├── TodoItem.m │ │ ├── TodoList.h │ │ ├── TodoList.m │ │ ├── TodoListAppDelegate.h │ │ ├── TodoListAppDelegate.m │ │ ├── TodoListViewController.h │ │ └── TodoListViewController.m │ ├── Default-568h@2x.png │ ├── HRTodoList-Info.plist │ ├── HRTodoList.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── HRTodoList.xcscheme │ ├── HRTodoList_Prefix.pch │ ├── MainWindow.xib │ ├── TodoList.plist │ ├── TodoListViewController.xib │ └── main.m ├── Libraries │ ├── CryptoCoding │ │ ├── CryptoCoding.h │ │ └── CryptoCoding.m │ ├── FastCoder │ │ ├── FastCoder.h │ │ └── FastCoder.m │ └── HRCoder │ │ ├── HRCoder.h │ │ └── HRCoder.m └── MacHRAutoTodoList │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── MacHRAutoTodoList │ ├── MacHRTodoList-Info.plist │ ├── MacHRTodoList-Prefix.pch │ ├── en.lproj │ │ ├── InfoPlist.strings │ │ └── MainMenu.xib │ ├── main.m │ └── thatch.jpg │ ├── MacHRTodoList.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata │ ├── TodoItem.m │ ├── TodoList.m │ ├── TodoList.plist │ └── Todos.h ├── LICENCE.md ├── README.md └── Tests ├── UnitTests.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── WorkspaceSettings.xcsettings └── xcshareddata │ └── xcschemes │ └── UnitTests.xcscheme └── UnitTests ├── BaseModelTests.m └── UnitTests-Info.plist /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode9 3 | 4 | script: xcodebuild test -project Tests/UnitTests.xcodeproj -scheme UnitTests -destination 'platform=iOS Simulator,name=iPhone 8 Plus,OS=11.0' 5 | -------------------------------------------------------------------------------- /BaseModel.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BaseModel", 3 | "version": "2.6.4", 4 | "summary": "BaseModel provides a base class for building model objects for your iOS or Mac OS projects.", 5 | "homepage": "https://github.com/nicklockwood/BaseModel", 6 | "license": "zlib", 7 | "authors": "Nick Lockwood", 8 | "source": { 9 | "git": "https://github.com/nicklockwood/BaseModel.git", 10 | "tag": "2.6.4" 11 | }, 12 | "requires_arc": true, 13 | "platforms": { 14 | "ios": "4.3", 15 | "tvos": "9.0", 16 | "osx": "10.6" 17 | }, 18 | "source_files": "BaseModel" 19 | } -------------------------------------------------------------------------------- /BaseModel/BaseModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseModel.h 3 | // 4 | // Version 2.6.4 5 | // 6 | // Created by Nick Lockwood on 25/06/2011. 7 | // Copyright 2011 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib license 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/BaseModel 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | 34 | #import 35 | 36 | 37 | extern NSString *const BaseModelSharedInstanceUpdatedNotification; 38 | extern NSString *const BaseModelException; 39 | 40 | 41 | typedef NS_ENUM(NSUInteger, BMFileFormat) 42 | { 43 | BMFileFormatKeyedArchive = 0, //default 44 | BMFileFormatXMLPropertyList, 45 | BMFileFormatBinaryPropertyList, 46 | BMFileFormatJSON, 47 | BMFileFormatUserDefaults, 48 | BMFileFormatKeychain, //requires FXKeychain library 49 | BMFileFormatCryptoCoding, //requires CryptoCoding library 50 | BMFileFormatHRCodedXML, //requires HRCoder library 51 | BMFileFormatHRCodedJSON, //requires HRCoder library 52 | BMFileFormatHRCodedBinary, //requires HRCoder library 53 | BMFileFormatFastCoding, //requires FastCoding library 54 | }; 55 | 56 | 57 | //use the BaseModel class as the base class for any of your 58 | //model objects. BaseModels can be standalone objects, or 59 | //act as sub-properties of a larger object 60 | 61 | @interface BaseModel : NSObject 62 | 63 | //loading sequence: 64 | //setUp called first 65 | //then setWithDictionary/Coder/etc if resource file exists 66 | //then setWithDictionary/Coder/etc again if save file exists 67 | //tearDown is called prior to dealloc (but only if setUp was called) 68 | 69 | - (void)setUp; 70 | - (void)setWithDictionary:(NSDictionary *)dict; 71 | - (void)setWithCoder:(NSCoder *)decoder; 72 | - (void)tearDown; 73 | 74 | //new autoreleased instance 75 | + (instancetype)instance; 76 | 77 | //shared (singelton) instance 78 | + (instancetype)sharedInstance; 79 | + (BOOL)hasSharedInstance; 80 | + (void)setSharedInstance:(BaseModel *)instance; 81 | + (void)reloadSharedInstance; 82 | 83 | //creating instances from a configuration object 84 | + (instancetype)instanceWithObject:(id)object; 85 | - (instancetype)initWithObject:(id)object; 86 | + (NSArray *)instancesWithArray:(NSArray *)array; 87 | 88 | //creating an instance using NSCoding 89 | + (instancetype)instanceWithCoder:(NSCoder *)decoder; 90 | - (instancetype)initWithCoder:(NSCoder *)decoder; 91 | 92 | //loading and saving the model from a data file 93 | + (instancetype)instanceWithContentsOfFile:(NSString *)path; 94 | - (instancetype)initWithContentsOfFile:(NSString *)path; 95 | - (BOOL)writeToFile:(NSString *)path atomically:(BOOL)atomically; 96 | - (BOOL)writeToFile:(NSString *)path format:(BMFileFormat)format atomically:(BOOL)atomically; 97 | 98 | //get model properties 99 | + (NSArray *)allPropertyKeys; 100 | + (NSArray *)codablePropertyKeys; 101 | - (NSDictionary *)dictionaryRepresentation; 102 | 103 | //resourceFile is a file, typically within the resource bundle that 104 | //is used to initialise any BaseModel instance 105 | //saveFile is a path, typically within application support that 106 | //is used to save the shared instance of the model 107 | //saveFormat is the preferred format to use when saving the file 108 | + (NSString *)resourceFile; 109 | + (NSString *)saveFile; 110 | + (BMFileFormat)saveFormat; 111 | 112 | //save the model 113 | - (BOOL)save; 114 | 115 | //generate unique identifier 116 | //useful for creating universally unique 117 | //identifiers and filenames for model objects 118 | + (NSString *)newUniqueIdentifier; 119 | 120 | @end 121 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/Classes/NewItemViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NewItemViewController.h 3 | // TodoList4 4 | // 5 | // Created by Nick Lockwood on 15/04/2010. 6 | // Copyright 2010 Charcoal Design. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class TodoItem; 12 | 13 | @interface NewItemViewController : UIViewController 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/Classes/NewItemViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // NewItemViewController.m 3 | // TodoList4 4 | // 5 | // Created by Nick Lockwood on 15/04/2010. 6 | // Copyright 2010 Charcoal Design. All rights reserved. 7 | // 8 | 9 | #import "NewItemViewController.h" 10 | #import "TodoList.h" 11 | #import "TodoItem.h" 12 | 13 | 14 | @interface NewItemViewController() 15 | 16 | @property (nonatomic, strong) TodoItem *item; 17 | 18 | @end 19 | 20 | 21 | @implementation NewItemViewController 22 | 23 | - (void)textViewDidChange:(UITextView *)textView 24 | { 25 | if (self.item == nil) 26 | { 27 | //create a new TodoItem and add to list 28 | self.item = [TodoItem instanceWithLabel:textView.text]; 29 | [[TodoList sharedInstance].items addObject:self.item]; 30 | } 31 | else 32 | { 33 | //update the TodoItem 34 | self.item.label = textView.text; 35 | } 36 | 37 | //save the item 38 | [self.item save]; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/Classes/NewItemViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/Classes/TodoItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // TodoItem.h 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 28/07/2011. 6 | // Copyright 2011 Charcoal Design. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | #import "BaseModel.h" 12 | 13 | 14 | @interface TodoItem : BaseModel 15 | 16 | @property (nonatomic, strong) NSString *label; 17 | @property (nonatomic, assign) BOOL checked; 18 | 19 | + (instancetype)instanceWithLabel:(NSString *)label; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/Classes/TodoItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // TodoItem.m 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 28/07/2011. 6 | // Copyright 2011 Charcoal Design. All rights reserved. 7 | // 8 | 9 | #import "TodoItem.h" 10 | #import "TodoList.h" 11 | 12 | 13 | @implementation TodoItem 14 | 15 | + (instancetype)instanceWithLabel:(NSString *)label 16 | { 17 | return [self instanceWithObject:label]; 18 | } 19 | 20 | - (void)setWithString:(NSString *)string 21 | { 22 | self.label = string; 23 | } 24 | 25 | - (BOOL)save 26 | { 27 | //save the todolist 28 | return [[TodoList sharedInstance] save]; 29 | } 30 | 31 | //NOTE: no need to implement the NSCoding methods 32 | //BaseModel does that for us automagically 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/Classes/TodoList.h: -------------------------------------------------------------------------------- 1 | // 2 | // TodoList.h 3 | // TodoListExample 4 | // 5 | // Created by Nick Lockwood on 28/07/2011. 6 | // Copyright 2011 Charcoal Design. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | #import "BaseModel.h" 12 | 13 | 14 | @interface TodoList : BaseModel 15 | 16 | @property (nonatomic, strong) NSMutableArray *items; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/Classes/TodoList.m: -------------------------------------------------------------------------------- 1 | // 2 | // TodoList.m 3 | // TodoListExample 4 | // 5 | // Created by Nick Lockwood on 28/07/2011. 6 | // Copyright 2011 Charcoal Design. All rights reserved. 7 | // 8 | 9 | #import "TodoList.h" 10 | #import "TodoItem.h" 11 | 12 | 13 | @implementation TodoList 14 | 15 | - (void)setUp 16 | { 17 | self.items = [NSMutableArray array]; 18 | } 19 | 20 | - (void)setWithArray:(NSArray *)array 21 | { 22 | //initialise with default list from plist 23 | [self.items setArray:[TodoItem instancesWithArray:array]]; 24 | } 25 | 26 | //NOTE: no need to implement the NSCoding methods 27 | //BaseModel does that for us automagically 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/Classes/TodoListAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // TodoListAppDelegate.h 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright Charcoal Design 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface TodoListAppDelegate : NSObject 13 | 14 | @property (nonatomic, strong) IBOutlet UIWindow *window; 15 | @property (nonatomic, strong) IBOutlet UIViewController *viewController; 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/Classes/TodoListAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // TodoListAppDelegate.m 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright Charcoal Design 2010. All rights reserved. 7 | // 8 | 9 | #import "TodoListAppDelegate.h" 10 | 11 | 12 | @implementation TodoListAppDelegate 13 | 14 | - (void)applicationDidFinishLaunching:(__unused UIApplication *)application 15 | { 16 | [self.window makeKeyAndVisible]; 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/Classes/TodoListViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TodoListViewController.h 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright Charcoal Design 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TodoListViewController : UITableViewController 12 | 13 | - (IBAction)createNewItem; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/Classes/TodoListViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TodoList1ViewController.m 3 | // TodoList1 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright AKQA 2010. All rights reserved. 7 | // 8 | 9 | #import "TodoListViewController.h" 10 | #import "NewItemViewController.h" 11 | #import "TodoItem.h" 12 | #import "TodoList.h" 13 | 14 | 15 | @implementation TodoListViewController 16 | 17 | - (void)viewDidLoad 18 | { 19 | [super viewDidLoad]; 20 | self.navigationItem.leftBarButtonItem = self.editButtonItem; 21 | self.clearsSelectionOnViewWillAppear = YES; 22 | } 23 | 24 | - (void)viewWillAppear:(__unused BOOL)animated 25 | { 26 | [super viewWillAppear:YES]; 27 | [self.tableView reloadData]; 28 | } 29 | 30 | - (IBAction)createNewItem 31 | { 32 | UIViewController *viewController = [[NewItemViewController alloc] init]; 33 | [self.navigationController pushViewController:viewController animated:YES]; 34 | } 35 | 36 | #pragma mark - 37 | #pragma mark UITableViewDelegate methods 38 | 39 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 40 | { 41 | TodoItem *item = [TodoList sharedInstance].items[(NSUInteger)indexPath.row]; 42 | item.checked = !item.checked; 43 | [item save]; 44 | 45 | [tableView reloadData]; 46 | } 47 | 48 | - (UITableViewCellEditingStyle)tableView:(__unused UITableView *)tableView editingStyleForRowAtIndexPath:(__unused NSIndexPath *)indexPath 49 | { 50 | return UITableViewCellEditingStyleDelete; 51 | } 52 | 53 | - (void)tableView:(UITableView *)tableView commitEditingStyle:(__unused UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 54 | { 55 | [[TodoList sharedInstance].items removeObjectAtIndex:(NSUInteger)indexPath.row]; 56 | [[TodoList sharedInstance] save]; 57 | 58 | [tableView reloadData]; 59 | } 60 | 61 | #pragma mark - 62 | #pragma mark UITableViewDataSource methods 63 | 64 | - (NSInteger)tableView:(__unused UITableView *)table numberOfRowsInSection:(__unused NSInteger)section 65 | { 66 | return (NSInteger)[[TodoList sharedInstance].items count]; 67 | } 68 | 69 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 70 | { 71 | static NSString *cellType = @"Cell"; 72 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellType]; 73 | if (cell == nil) 74 | { 75 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellType]; 76 | } 77 | 78 | TodoItem *item = [TodoList sharedInstance].items[(NSUInteger)indexPath.row]; 79 | cell.textLabel.text = item.label; 80 | cell.accessoryType = item.checked? UITableViewCellAccessoryCheckmark: UITableViewCellAccessoryNone; 81 | return cell; 82 | } 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicklockwood/BaseModel/c503c8f6ce0a826e3c27ce500686eefd1fe0d52a/Examples/BasicTodoList/Default-568h@2x.png -------------------------------------------------------------------------------- /Examples/BasicTodoList/MainWindow.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/TodoList-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | 30 | 31 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/TodoList.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Do washing 6 | Mow lawn 7 | Write an open source library 8 | Feed the cat 9 | 10 | 11 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/TodoList.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/TodoListViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/TodoList_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'TodoList1' target in the 'TodoList1' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /Examples/BasicTodoList/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TodoList1 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright Charcoal Design 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) { 12 | 13 | @autoreleasepool 14 | { 15 | return UIApplicationMain(argc, argv, nil, nil); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/Classes/NewItemViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NewItemViewController.h 3 | // TodoList4 4 | // 5 | // Created by Nick Lockwood on 15/04/2010. 6 | // Copyright 2010 Charcoal Design. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class TodoItem; 12 | 13 | @interface NewItemViewController : UIViewController 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/Classes/NewItemViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // NewItemViewController.m 3 | // TodoList4 4 | // 5 | // Created by Nick Lockwood on 15/04/2010. 6 | // Copyright 2010 Charcoal Design. All rights reserved. 7 | // 8 | 9 | #import "NewItemViewController.h" 10 | #import "TodoList.h" 11 | #import "TodoItem.h" 12 | 13 | 14 | @interface NewItemViewController() 15 | 16 | @property (nonatomic, strong) TodoItem *item; 17 | 18 | @end 19 | 20 | 21 | @implementation NewItemViewController 22 | 23 | @synthesize item; 24 | 25 | #pragma mark - 26 | #pragma mark UITextViewDelegate methods 27 | 28 | - (void)textViewDidChange:(UITextView *)textView 29 | { 30 | if (item == nil) 31 | { 32 | //create a new TodoItem and add to list 33 | self.item = [TodoItem instanceWithLabel:textView.text]; 34 | [[TodoList sharedInstance].items addObject:item]; 35 | } 36 | else 37 | { 38 | //update the TodoItem 39 | item.label = textView.text; 40 | } 41 | 42 | //save the item 43 | [item save]; 44 | } 45 | 46 | #pragma mark - 47 | #pragma mark Cleanup 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/Classes/NewItemViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 800 5 | 10D573 6 | 762 7 | 1038.29 8 | 460.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 87 12 | 13 | 14 | YES 15 | 16 | 17 | 18 | YES 19 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 20 | 21 | 22 | YES 23 | 24 | YES 25 | 26 | 27 | YES 28 | 29 | 30 | 31 | YES 32 | 33 | IBFilesOwner 34 | IBCocoaTouchFramework 35 | 36 | 37 | IBFirstResponder 38 | IBCocoaTouchFramework 39 | 40 | 41 | 42 | 274 43 | 44 | YES 45 | 46 | 47 | 274 48 | {320, 460} 49 | 50 | 51 | 1 52 | MSAxIDEAA 53 | 54 | YES 55 | YES 56 | IBCocoaTouchFramework 57 | NO 58 | NO 59 | NO 60 | NO 61 | 62 | 63 | 2 64 | IBCocoaTouchFramework 65 | 66 | 67 | 68 | {320, 460} 69 | 70 | 71 | 3 72 | MQA 73 | 74 | 2 75 | 76 | 77 | 78 | IBCocoaTouchFramework 79 | 80 | 81 | 82 | 83 | YES 84 | 85 | 86 | view 87 | 88 | 89 | 90 | 3 91 | 92 | 93 | 94 | delegate 95 | 96 | 97 | 98 | 8 99 | 100 | 101 | 102 | 103 | YES 104 | 105 | 0 106 | 107 | 108 | 109 | 110 | 111 | 1 112 | 113 | 114 | YES 115 | 116 | 117 | 118 | 119 | 120 | -1 121 | 122 | 123 | File's Owner 124 | 125 | 126 | -2 127 | 128 | 129 | 130 | 131 | 7 132 | 133 | 134 | 135 | 136 | 137 | 138 | YES 139 | 140 | YES 141 | -1.CustomClassName 142 | -2.CustomClassName 143 | 1.IBEditorWindowLastContentRect 144 | 1.IBPluginDependency 145 | 7.IBPluginDependency 146 | 147 | 148 | YES 149 | NewItemViewController 150 | UIResponder 151 | {{556, 412}, {320, 480}} 152 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 153 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 154 | 155 | 156 | 157 | YES 158 | 159 | 160 | YES 161 | 162 | 163 | 164 | 165 | YES 166 | 167 | 168 | YES 169 | 170 | 171 | 172 | 8 173 | 174 | 175 | 176 | YES 177 | 178 | NewItemViewController 179 | UIViewController 180 | 181 | IBProjectSource 182 | Classes/NewItemViewController.h 183 | 184 | 185 | 186 | 187 | YES 188 | 189 | NSObject 190 | 191 | IBFrameworkSource 192 | Foundation.framework/Headers/NSError.h 193 | 194 | 195 | 196 | NSObject 197 | 198 | IBFrameworkSource 199 | Foundation.framework/Headers/NSFileManager.h 200 | 201 | 202 | 203 | NSObject 204 | 205 | IBFrameworkSource 206 | Foundation.framework/Headers/NSKeyValueCoding.h 207 | 208 | 209 | 210 | NSObject 211 | 212 | IBFrameworkSource 213 | Foundation.framework/Headers/NSKeyValueObserving.h 214 | 215 | 216 | 217 | NSObject 218 | 219 | IBFrameworkSource 220 | Foundation.framework/Headers/NSKeyedArchiver.h 221 | 222 | 223 | 224 | NSObject 225 | 226 | IBFrameworkSource 227 | Foundation.framework/Headers/NSNetServices.h 228 | 229 | 230 | 231 | NSObject 232 | 233 | IBFrameworkSource 234 | Foundation.framework/Headers/NSObject.h 235 | 236 | 237 | 238 | NSObject 239 | 240 | IBFrameworkSource 241 | Foundation.framework/Headers/NSPort.h 242 | 243 | 244 | 245 | NSObject 246 | 247 | IBFrameworkSource 248 | Foundation.framework/Headers/NSRunLoop.h 249 | 250 | 251 | 252 | NSObject 253 | 254 | IBFrameworkSource 255 | Foundation.framework/Headers/NSStream.h 256 | 257 | 258 | 259 | NSObject 260 | 261 | IBFrameworkSource 262 | Foundation.framework/Headers/NSThread.h 263 | 264 | 265 | 266 | NSObject 267 | 268 | IBFrameworkSource 269 | Foundation.framework/Headers/NSURL.h 270 | 271 | 272 | 273 | NSObject 274 | 275 | IBFrameworkSource 276 | Foundation.framework/Headers/NSURLConnection.h 277 | 278 | 279 | 280 | NSObject 281 | 282 | IBFrameworkSource 283 | Foundation.framework/Headers/NSXMLParser.h 284 | 285 | 286 | 287 | NSObject 288 | 289 | IBFrameworkSource 290 | UIKit.framework/Headers/UIAccessibility.h 291 | 292 | 293 | 294 | NSObject 295 | 296 | IBFrameworkSource 297 | UIKit.framework/Headers/UINibLoading.h 298 | 299 | 300 | 301 | NSObject 302 | 303 | IBFrameworkSource 304 | UIKit.framework/Headers/UIResponder.h 305 | 306 | 307 | 308 | UIResponder 309 | NSObject 310 | 311 | 312 | 313 | UIScrollView 314 | UIView 315 | 316 | IBFrameworkSource 317 | UIKit.framework/Headers/UIScrollView.h 318 | 319 | 320 | 321 | UISearchBar 322 | UIView 323 | 324 | IBFrameworkSource 325 | UIKit.framework/Headers/UISearchBar.h 326 | 327 | 328 | 329 | UISearchDisplayController 330 | NSObject 331 | 332 | IBFrameworkSource 333 | UIKit.framework/Headers/UISearchDisplayController.h 334 | 335 | 336 | 337 | UITextView 338 | UIScrollView 339 | 340 | IBFrameworkSource 341 | UIKit.framework/Headers/UITextView.h 342 | 343 | 344 | 345 | UIView 346 | 347 | IBFrameworkSource 348 | UIKit.framework/Headers/UITextField.h 349 | 350 | 351 | 352 | UIView 353 | UIResponder 354 | 355 | IBFrameworkSource 356 | UIKit.framework/Headers/UIView.h 357 | 358 | 359 | 360 | UIViewController 361 | 362 | IBFrameworkSource 363 | UIKit.framework/Headers/UINavigationController.h 364 | 365 | 366 | 367 | UIViewController 368 | 369 | IBFrameworkSource 370 | UIKit.framework/Headers/UITabBarController.h 371 | 372 | 373 | 374 | UIViewController 375 | UIResponder 376 | 377 | IBFrameworkSource 378 | UIKit.framework/Headers/UIViewController.h 379 | 380 | 381 | 382 | 383 | 0 384 | IBCocoaTouchFramework 385 | 386 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 387 | 388 | 389 | YES 390 | ../TodoList4.xcodeproj 391 | 3 392 | 87 393 | 394 | 395 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/Classes/TodoItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // TodoItem.h 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 28/07/2011. 6 | // Copyright 2011 Charcoal Design. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | #import "BaseModel.h" 12 | 13 | 14 | @interface TodoItem : BaseModel 15 | 16 | @property (nonatomic, strong) NSString *label; 17 | @property (nonatomic, assign) BOOL checked; 18 | 19 | + (instancetype)instanceWithLabel:(NSString *)label; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/Classes/TodoItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // TodoItem.m 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 28/07/2011. 6 | // Copyright 2011 Charcoal Design. All rights reserved. 7 | // 8 | 9 | #import "TodoItem.h" 10 | #import "TodoList.h" 11 | 12 | 13 | @implementation TodoItem 14 | 15 | + (instancetype)instanceWithLabel:(NSString *)label 16 | { 17 | return [self instanceWithObject:label]; 18 | } 19 | 20 | - (void)setWithString:(NSString *)string 21 | { 22 | self.label = string; 23 | } 24 | 25 | - (BOOL)save 26 | { 27 | //save the todolist 28 | return [[TodoList sharedInstance] save]; 29 | } 30 | 31 | //NOTE: no need to implement the NSCoding methods 32 | //BaseModel does that for us automagically 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/Classes/TodoList.h: -------------------------------------------------------------------------------- 1 | // 2 | // TodoList.h 3 | // TodoListExample 4 | // 5 | // Created by Nick Lockwood on 28/07/2011. 6 | // Copyright 2011 Charcoal Design. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | #import "BaseModel.h" 12 | 13 | 14 | @interface TodoList : BaseModel 15 | 16 | @property (nonatomic, strong) NSMutableArray *items; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/Classes/TodoList.m: -------------------------------------------------------------------------------- 1 | // 2 | // TodoList.m 3 | // TodoListExample 4 | // 5 | // Created by Nick Lockwood on 28/07/2011. 6 | // Copyright 2011 Charcoal Design. All rights reserved. 7 | // 8 | 9 | #import "TodoList.h" 10 | #import "TodoItem.h" 11 | 12 | 13 | @implementation TodoList 14 | 15 | @synthesize items; 16 | 17 | //all we have to do to add automatic encryption 18 | //support is to add the CryptoCoding class files and 19 | //Security framework to the project, set the saveFormat 20 | //to BMFileFormatCryptoCoding, and then use the 21 | //+CCPassword method to specify a password for our model 22 | 23 | + (BMFileFormat)saveFormat 24 | { 25 | return BMFileFormatCryptoCoding; 26 | } 27 | 28 | + (NSString *)CCPassword 29 | { 30 | return @"YsMXOHm2vsoIxTdSZWMILEVnQtgupefHGSROCLmwTnX3wBaCac"; 31 | } 32 | 33 | - (void)setUp 34 | { 35 | self.items = [NSMutableArray array]; 36 | } 37 | 38 | - (void)setWithArray:(NSArray *)array 39 | { 40 | //initialise with default list from plist 41 | [items setArray:[TodoItem instancesWithArray:array]]; 42 | } 43 | 44 | //NOTE: no need to implement the NSCoding methods 45 | //BaseModel does that for us automagically 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/Classes/TodoListAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // TodoListAppDelegate.h 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright Charcoal Design 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface TodoListAppDelegate : NSObject 13 | 14 | @property (nonatomic, strong) IBOutlet UIWindow *window; 15 | @property (nonatomic, strong) IBOutlet UIViewController *viewController; 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/Classes/TodoListAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // TodoListAppDelegate.m 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright Charcoal Design 2010. All rights reserved. 7 | // 8 | 9 | #import "TodoListAppDelegate.h" 10 | 11 | 12 | @implementation TodoListAppDelegate 13 | 14 | @synthesize window; 15 | @synthesize viewController; 16 | 17 | - (void)applicationDidFinishLaunching:(UIApplication *)application 18 | { 19 | [window makeKeyAndVisible]; 20 | } 21 | 22 | 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/Classes/TodoListViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TodoListViewController.h 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright Charcoal Design 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TodoListViewController : UITableViewController 12 | 13 | - (IBAction)createNewItem; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/Classes/TodoListViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TodoList1ViewController.m 3 | // TodoList1 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright AKQA 2010. All rights reserved. 7 | // 8 | 9 | #import "TodoListViewController.h" 10 | #import "NewItemViewController.h" 11 | #import "TodoItem.h" 12 | #import "TodoList.h" 13 | 14 | 15 | @implementation TodoListViewController 16 | 17 | - (void)viewDidLoad 18 | { 19 | [super viewDidLoad]; 20 | self.navigationItem.leftBarButtonItem = self.editButtonItem; 21 | self.clearsSelectionOnViewWillAppear = YES; 22 | } 23 | 24 | - (void)viewWillAppear:(BOOL)animated 25 | { 26 | [super viewWillAppear:YES]; 27 | [self.tableView reloadData]; 28 | } 29 | 30 | - (IBAction)createNewItem 31 | { 32 | UIViewController *viewController = [[NewItemViewController alloc] init]; 33 | [self.navigationController pushViewController:viewController animated:YES]; 34 | } 35 | 36 | #pragma mark - 37 | #pragma mark UITableViewDelegate methods 38 | 39 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 40 | { 41 | TodoItem *item = [[TodoList sharedInstance].items objectAtIndex:indexPath.row]; 42 | item.checked = !item.checked; 43 | [item save]; 44 | 45 | [tableView reloadData]; 46 | } 47 | 48 | - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 49 | { 50 | return UITableViewCellEditingStyleDelete; 51 | } 52 | 53 | - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 54 | { 55 | [[TodoList sharedInstance].items removeObjectAtIndex:indexPath.row]; 56 | [[TodoList sharedInstance] save]; 57 | 58 | [tableView reloadData]; 59 | } 60 | 61 | #pragma mark - 62 | #pragma mark UITableViewDataSource methods 63 | 64 | - (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section 65 | { 66 | return [[TodoList sharedInstance].items count]; 67 | } 68 | 69 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 70 | { 71 | static NSString *cellType = @"Cell"; 72 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellType]; 73 | if (cell == nil) 74 | { 75 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellType]; 76 | } 77 | 78 | TodoItem *item = [[TodoList sharedInstance].items objectAtIndex:indexPath.row]; 79 | cell.textLabel.text = item.label; 80 | if (item.checked) { 81 | cell.accessoryType = UITableViewCellAccessoryCheckmark; 82 | } else { 83 | cell.accessoryType = UITableViewCellAccessoryNone; 84 | } 85 | 86 | return cell; 87 | } 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/CryptoTodoList-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | 30 | 31 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/CryptoTodoList.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/CryptoTodoList_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'TodoList1' target in the 'TodoList1' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicklockwood/BaseModel/c503c8f6ce0a826e3c27ce500686eefd1fe0d52a/Examples/CryptoTodoList/Default-568h@2x.png -------------------------------------------------------------------------------- /Examples/CryptoTodoList/MainWindow.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1056 5 | 10K549 6 | 1306 7 | 1038.36 8 | 461.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 301 12 | 13 | 14 | YES 15 | IBProxyObject 16 | IBUINavigationController 17 | IBUIViewController 18 | IBUICustomObject 19 | IBUIBarButtonItem 20 | IBUIWindow 21 | IBUINavigationBar 22 | IBUINavigationItem 23 | 24 | 25 | YES 26 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 27 | 28 | 29 | YES 30 | 31 | YES 32 | 33 | 34 | 35 | 36 | YES 37 | 38 | IBFilesOwner 39 | IBCocoaTouchFramework 40 | 41 | 42 | IBFirstResponder 43 | IBCocoaTouchFramework 44 | 45 | 46 | IBCocoaTouchFramework 47 | 48 | 49 | 50 | 51 | 1 52 | 1 53 | 54 | IBCocoaTouchFramework 55 | NO 56 | 57 | 58 | 256 59 | {0, 0} 60 | NO 61 | YES 62 | YES 63 | IBCocoaTouchFramework 64 | 65 | 66 | YES 67 | 68 | 69 | 70 | Todo List 71 | 72 | Edit 73 | IBCocoaTouchFramework 74 | 1 75 | 76 | 77 | 78 | New 79 | IBCocoaTouchFramework 80 | 1 81 | 82 | 83 | IBCocoaTouchFramework 84 | 85 | 86 | TodoListViewController 87 | 88 | 89 | 1 90 | 1 91 | 92 | IBCocoaTouchFramework 93 | NO 94 | 95 | 96 | 97 | 98 | 99 | 292 100 | {320, 480} 101 | 102 | 1 103 | MSAxIDEAA 104 | 105 | NO 106 | NO 107 | 108 | IBCocoaTouchFramework 109 | 110 | 111 | 112 | 113 | YES 114 | 115 | 116 | delegate 117 | 118 | 119 | 120 | 4 121 | 122 | 123 | 124 | window 125 | 126 | 127 | 128 | 14 129 | 130 | 131 | 132 | viewController 133 | 134 | 135 | 136 | 20 137 | 138 | 139 | 140 | toggleEditing: 141 | 142 | 143 | 144 | 23 145 | 146 | 147 | 148 | createNewItem 149 | 150 | 151 | 152 | 25 153 | 154 | 155 | 156 | rootViewController 157 | 158 | 159 | 160 | 26 161 | 162 | 163 | 164 | 165 | YES 166 | 167 | 0 168 | 169 | 170 | 171 | 172 | 173 | -1 174 | 175 | 176 | File's Owner 177 | 178 | 179 | 3 180 | 181 | 182 | TodoList3 App Delegate 183 | 184 | 185 | -2 186 | 187 | 188 | 189 | 190 | 12 191 | 192 | 193 | 194 | 195 | 15 196 | 197 | 198 | YES 199 | 200 | 201 | 202 | 203 | 204 | 205 | 17 206 | 207 | 208 | 209 | 210 | 10 211 | 212 | 213 | YES 214 | 215 | 216 | 217 | TodoList View Controller 218 | 219 | 220 | 19 221 | 222 | 223 | YES 224 | 225 | 226 | 227 | 228 | 229 | 230 | 21 231 | 232 | 233 | 234 | 235 | 24 236 | 237 | 238 | 239 | 240 | 241 | 242 | YES 243 | 244 | YES 245 | -1.CustomClassName 246 | -2.CustomClassName 247 | 10.CustomClassName 248 | 10.IBEditorWindowLastContentRect 249 | 10.IBPluginDependency 250 | 12.IBEditorWindowLastContentRect 251 | 12.IBPluginDependency 252 | 15.IBEditorWindowLastContentRect 253 | 15.IBPluginDependency 254 | 17.IBPluginDependency 255 | 21.IBPluginDependency 256 | 24.IBPluginDependency 257 | 3.CustomClassName 258 | 3.IBPluginDependency 259 | 260 | 261 | YES 262 | UIApplication 263 | UIResponder 264 | TodoListViewController 265 | {{512, 351}, {320, 480}} 266 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 267 | {{525, 346}, {320, 480}} 268 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 269 | {{42, 619}, {320, 480}} 270 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 271 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 272 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 273 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 274 | TodoListAppDelegate 275 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 276 | 277 | 278 | 279 | YES 280 | 281 | 282 | 283 | 284 | 285 | YES 286 | 287 | 288 | 289 | 290 | 26 291 | 292 | 293 | 294 | YES 295 | 296 | TodoListAppDelegate 297 | NSObject 298 | 299 | YES 300 | 301 | YES 302 | viewController 303 | window 304 | 305 | 306 | YES 307 | UIViewController 308 | UIWindow 309 | 310 | 311 | 312 | YES 313 | 314 | YES 315 | viewController 316 | window 317 | 318 | 319 | YES 320 | 321 | viewController 322 | UIViewController 323 | 324 | 325 | window 326 | UIWindow 327 | 328 | 329 | 330 | 331 | IBProjectSource 332 | ./Classes/TodoListAppDelegate.h 333 | 334 | 335 | 336 | TodoListViewController 337 | UITableViewController 338 | 339 | createNewItem 340 | id 341 | 342 | 343 | createNewItem 344 | 345 | createNewItem 346 | id 347 | 348 | 349 | 350 | IBProjectSource 351 | ./Classes/TodoListViewController.h 352 | 353 | 354 | 355 | 356 | 0 357 | IBCocoaTouchFramework 358 | 359 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 360 | 361 | 362 | YES 363 | 3 364 | 301 365 | 366 | 367 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/TodoList.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Do washing 6 | Mow lawn 7 | Write an open source library 8 | Feed the cat 9 | 10 | 11 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/TodoListViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1056 5 | 10K549 6 | 1306 7 | 1038.36 8 | 461.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 301 12 | 13 | 14 | YES 15 | IBProxyObject 16 | IBUITableView 17 | 18 | 19 | YES 20 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 21 | 22 | 23 | YES 24 | 25 | YES 26 | 27 | 28 | 29 | 30 | YES 31 | 32 | IBFilesOwner 33 | IBCocoaTouchFramework 34 | 35 | 36 | IBFirstResponder 37 | IBCocoaTouchFramework 38 | 39 | 40 | 41 | 274 42 | {320, 460} 43 | 44 | 45 | 46 | 47 | 3 48 | MQA 49 | 50 | NO 51 | YES 52 | NO 53 | IBCocoaTouchFramework 54 | NO 55 | 1 56 | 0 57 | YES 58 | 44 59 | 22 60 | 22 61 | 62 | 63 | 64 | 65 | YES 66 | 67 | 68 | tableView 69 | 70 | 71 | 72 | 17 73 | 74 | 75 | 76 | view 77 | 78 | 79 | 80 | 19 81 | 82 | 83 | 84 | dataSource 85 | 86 | 87 | 88 | 20 89 | 90 | 91 | 92 | delegate 93 | 94 | 95 | 96 | 21 97 | 98 | 99 | 100 | 101 | YES 102 | 103 | 0 104 | 105 | 106 | 107 | 108 | 109 | -1 110 | 111 | 112 | File's Owner 113 | 114 | 115 | -2 116 | 117 | 118 | 119 | 120 | 8 121 | 122 | 123 | 124 | 125 | 126 | 127 | YES 128 | 129 | YES 130 | -1.CustomClassName 131 | -2.CustomClassName 132 | 8.IBPluginDependency 133 | 134 | 135 | YES 136 | TodoListViewController 137 | UIResponder 138 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 139 | 140 | 141 | 142 | YES 143 | 144 | 145 | 146 | 147 | 148 | YES 149 | 150 | 151 | 152 | 153 | 21 154 | 155 | 156 | 157 | YES 158 | 159 | TodoListViewController 160 | UITableViewController 161 | 162 | createNewItem 163 | id 164 | 165 | 166 | createNewItem 167 | 168 | createNewItem 169 | id 170 | 171 | 172 | 173 | IBProjectSource 174 | ./Classes/TodoListViewController.h 175 | 176 | 177 | 178 | 179 | 0 180 | IBCocoaTouchFramework 181 | 182 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 183 | 184 | 185 | YES 186 | 3 187 | 301 188 | 189 | 190 | -------------------------------------------------------------------------------- /Examples/CryptoTodoList/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TodoList1 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright Charcoal Design 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) { 12 | 13 | @autoreleasepool { 14 | int retVal = UIApplicationMain(argc, argv, nil, nil); 15 | return retVal; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Examples/FCTodoList/Classes/NewItemViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NewItemViewController.h 3 | // TodoList4 4 | // 5 | // Created by Nick Lockwood on 15/04/2010. 6 | // Copyright 2010 Charcoal Design. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class TodoItem; 12 | 13 | @interface NewItemViewController : UIViewController 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Examples/FCTodoList/Classes/NewItemViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // NewItemViewController.m 3 | // TodoList4 4 | // 5 | // Created by Nick Lockwood on 15/04/2010. 6 | // Copyright 2010 Charcoal Design. All rights reserved. 7 | // 8 | 9 | #import "NewItemViewController.h" 10 | #import "TodoList.h" 11 | #import "TodoItem.h" 12 | 13 | 14 | @interface NewItemViewController() 15 | 16 | @property (nonatomic, strong) TodoItem *item; 17 | 18 | @end 19 | 20 | 21 | @implementation NewItemViewController 22 | 23 | @synthesize item; 24 | 25 | #pragma mark - 26 | #pragma mark UITextViewDelegate methods 27 | 28 | - (void)textViewDidChange:(UITextView *)textView 29 | { 30 | if (item == nil) 31 | { 32 | //create a new TodoItem and add to list 33 | self.item = [TodoItem instanceWithLabel:textView.text]; 34 | [[TodoList sharedInstance].items addObject:item]; 35 | } 36 | else 37 | { 38 | //update the TodoItem 39 | item.label = textView.text; 40 | } 41 | 42 | //save the item 43 | [item save]; 44 | } 45 | 46 | #pragma mark - 47 | #pragma mark Cleanup 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Examples/FCTodoList/Classes/NewItemViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Examples/FCTodoList/Classes/TodoItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // TodoItem.h 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 28/07/2011. 6 | // Copyright 2011 Charcoal Design. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | #import "BaseModel.h" 12 | 13 | 14 | @interface TodoItem : BaseModel 15 | 16 | @property (nonatomic, strong) NSString *label; 17 | @property (nonatomic, assign) BOOL checked; 18 | 19 | + (instancetype)instanceWithLabel:(NSString *)label; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Examples/FCTodoList/Classes/TodoItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // TodoItem.m 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 28/07/2011. 6 | // Copyright 2011 Charcoal Design. All rights reserved. 7 | // 8 | 9 | #import "TodoItem.h" 10 | #import "TodoList.h" 11 | 12 | 13 | @implementation TodoItem 14 | 15 | + (instancetype)instanceWithLabel:(NSString *)label 16 | { 17 | TodoItem *instance = [self instance]; 18 | instance.label = label; 19 | return instance; 20 | } 21 | 22 | - (BOOL)save 23 | { 24 | //save the todolist 25 | return [[TodoList sharedInstance] save]; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Examples/FCTodoList/Classes/TodoList.h: -------------------------------------------------------------------------------- 1 | // 2 | // TodoList.h 3 | // TodoListExample 4 | // 5 | // Created by Nick Lockwood on 28/07/2011. 6 | // Copyright 2011 Charcoal Design. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | #import "BaseModel.h" 12 | 13 | 14 | @interface TodoList : BaseModel 15 | 16 | @property (nonatomic, strong) NSMutableArray *items; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Examples/FCTodoList/Classes/TodoList.m: -------------------------------------------------------------------------------- 1 | // 2 | // TodoList.m 3 | // TodoListExample 4 | // 5 | // Created by Nick Lockwood on 28/07/2011. 6 | // Copyright 2011 Charcoal Design. All rights reserved. 7 | // 8 | 9 | #import "TodoList.h" 10 | #import "TodoItem.h" 11 | 12 | 13 | @implementation TodoList 14 | 15 | + (BMFileFormat)saveFormat 16 | { 17 | //this is the format that will be used to save the model 18 | return BMFileFormatFastCoding; 19 | } 20 | 21 | - (void)setUp 22 | { 23 | self.items = [NSMutableArray array]; 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Examples/FCTodoList/Classes/TodoListAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // TodoListAppDelegate.h 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright Charcoal Design 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface TodoListAppDelegate : NSObject 13 | 14 | @property (nonatomic, strong) IBOutlet UIWindow *window; 15 | @property (nonatomic, strong) IBOutlet UIViewController *viewController; 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /Examples/FCTodoList/Classes/TodoListAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // TodoListAppDelegate.m 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright Charcoal Design 2010. All rights reserved. 7 | // 8 | 9 | #import "TodoListAppDelegate.h" 10 | 11 | 12 | @implementation TodoListAppDelegate 13 | 14 | - (void)applicationDidFinishLaunching:(UIApplication *)application 15 | { 16 | [_window makeKeyAndVisible]; 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Examples/FCTodoList/Classes/TodoListViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TodoListViewController.h 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright Charcoal Design 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TodoListViewController : UITableViewController 12 | 13 | - (IBAction)createNewItem; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /Examples/FCTodoList/Classes/TodoListViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TodoList1ViewController.m 3 | // TodoList1 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright AKQA 2010. All rights reserved. 7 | // 8 | 9 | #import "TodoListViewController.h" 10 | #import "NewItemViewController.h" 11 | #import "TodoItem.h" 12 | #import "TodoList.h" 13 | 14 | 15 | @implementation TodoListViewController 16 | 17 | - (void)viewDidLoad 18 | { 19 | [super viewDidLoad]; 20 | self.navigationItem.leftBarButtonItem = self.editButtonItem; 21 | self.clearsSelectionOnViewWillAppear = YES; 22 | } 23 | 24 | - (void)viewWillAppear:(BOOL)animated 25 | { 26 | [super viewWillAppear:YES]; 27 | [self.tableView reloadData]; 28 | } 29 | 30 | - (IBAction)createNewItem 31 | { 32 | UIViewController *viewController = [[NewItemViewController alloc] init]; 33 | [self.navigationController pushViewController:viewController animated:YES]; 34 | } 35 | 36 | #pragma mark - 37 | #pragma mark UITableViewDelegate methods 38 | 39 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 40 | { 41 | TodoItem *item = [[TodoList sharedInstance].items objectAtIndex:indexPath.row]; 42 | item.checked = !item.checked; 43 | [item save]; 44 | 45 | [tableView reloadData]; 46 | } 47 | 48 | - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 49 | { 50 | return UITableViewCellEditingStyleDelete; 51 | } 52 | 53 | - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 54 | { 55 | [[TodoList sharedInstance].items removeObjectAtIndex:indexPath.row]; 56 | [[TodoList sharedInstance] save]; 57 | 58 | [tableView reloadData]; 59 | } 60 | 61 | #pragma mark - 62 | #pragma mark UITableViewDataSource methods 63 | 64 | - (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section 65 | { 66 | return [[TodoList sharedInstance].items count]; 67 | } 68 | 69 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 70 | { 71 | static NSString *cellType = @"Cell"; 72 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellType]; 73 | if (cell == nil) 74 | { 75 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellType]; 76 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 77 | } 78 | 79 | TodoItem *item = [[TodoList sharedInstance].items objectAtIndex:indexPath.row]; 80 | cell.textLabel.text = item.label; 81 | cell.accessoryType = item.checked? UITableViewCellAccessoryCheckmark: UITableViewCellAccessoryNone; 82 | 83 | return cell; 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /Examples/FCTodoList/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicklockwood/BaseModel/c503c8f6ce0a826e3c27ce500686eefd1fe0d52a/Examples/FCTodoList/Default-568h@2x.png -------------------------------------------------------------------------------- /Examples/FCTodoList/FCTodoList-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | 30 | 31 | -------------------------------------------------------------------------------- /Examples/FCTodoList/FCTodoList.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 01457AEB117723E2005BBF82 /* NewItemViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 01457AE9117723E2005BBF82 /* NewItemViewController.m */; }; 11 | 01457AEC117723E2005BBF82 /* NewItemViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 01457AEA117723E2005BBF82 /* NewItemViewController.xib */; }; 12 | 01864D4D1861E2D00081685A /* FastCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 01864D4C1861E2D00081685A /* FastCoder.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 13 | 01CDB20C161133F600B929AD /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 01CDB20B161133F600B929AD /* Default-568h@2x.png */; }; 14 | 1D3623260D0F684500981E51 /* TodoListAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* TodoListAppDelegate.m */; }; 15 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; 16 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 17 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 18 | 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; 19 | 2899E5220DE3E06400AC0155 /* TodoListViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2899E5210DE3E06400AC0155 /* TodoListViewController.xib */; }; 20 | 28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; }; 21 | 28D7ACF80DDB3853001CB0EB /* TodoListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* TodoListViewController.m */; }; 22 | B25BC0FB146AA0FB00008FB3 /* BaseModel.m in Sources */ = {isa = PBXBuildFile; fileRef = B25BC0FA146AA0FB00008FB3 /* BaseModel.m */; }; 23 | B2CE7D5413E1729C00AB7DB4 /* TodoItem.m in Sources */ = {isa = PBXBuildFile; fileRef = B2CE7D5313E1729C00AB7DB4 /* TodoItem.m */; }; 24 | B2CE7D5713E172A700AB7DB4 /* TodoList.m in Sources */ = {isa = PBXBuildFile; fileRef = B2CE7D5513E172A700AB7DB4 /* TodoList.m */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | 01457AE8117723E2005BBF82 /* NewItemViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewItemViewController.h; sourceTree = ""; }; 29 | 01457AE9117723E2005BBF82 /* NewItemViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewItemViewController.m; sourceTree = ""; }; 30 | 01457AEA117723E2005BBF82 /* NewItemViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = NewItemViewController.xib; path = Classes/NewItemViewController.xib; sourceTree = ""; }; 31 | 01864D4B1861E2D00081685A /* FastCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FastCoder.h; sourceTree = ""; }; 32 | 01864D4C1861E2D00081685A /* FastCoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FastCoder.m; sourceTree = ""; }; 33 | 01CDB20B161133F600B929AD /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 34 | 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 35 | 1D3623240D0F684500981E51 /* TodoListAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TodoListAppDelegate.h; path = Classes/TodoListAppDelegate.h; sourceTree = SOURCE_ROOT; }; 36 | 1D3623250D0F684500981E51 /* TodoListAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TodoListAppDelegate.m; sourceTree = ""; }; 37 | 1D6058910D05DD3D006BFB54 /* FCTodoList.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FCTodoList.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 39 | 288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 40 | 2899E5210DE3E06400AC0155 /* TodoListViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TodoListViewController.xib; sourceTree = ""; }; 41 | 28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; 42 | 28D7ACF60DDB3853001CB0EB /* TodoListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TodoListViewController.h; sourceTree = ""; }; 43 | 28D7ACF70DDB3853001CB0EB /* TodoListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TodoListViewController.m; sourceTree = ""; }; 44 | 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 45 | 32CA4F630368D1EE00C91783 /* FCTodoList_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FCTodoList_Prefix.pch; sourceTree = ""; }; 46 | 8D1107310486CEB800E47090 /* FCTodoList-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "FCTodoList-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; 47 | B25BC0F9146AA0FB00008FB3 /* BaseModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseModel.h; sourceTree = ""; }; 48 | B25BC0FA146AA0FB00008FB3 /* BaseModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BaseModel.m; sourceTree = ""; }; 49 | B2CE7D5213E1729C00AB7DB4 /* TodoItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TodoItem.h; sourceTree = ""; }; 50 | B2CE7D5313E1729C00AB7DB4 /* TodoItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TodoItem.m; sourceTree = ""; }; 51 | B2CE7D5513E172A700AB7DB4 /* TodoList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TodoList.m; sourceTree = ""; }; 52 | B2CE7D5613E172A700AB7DB4 /* TodoList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TodoList.h; sourceTree = ""; }; 53 | /* End PBXFileReference section */ 54 | 55 | /* Begin PBXFrameworksBuildPhase section */ 56 | 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, 61 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, 62 | 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */, 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | /* End PBXFrameworksBuildPhase section */ 67 | 68 | /* Begin PBXGroup section */ 69 | 01457AF311772690005BBF82 /* View Controllers */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | 1D3623240D0F684500981E51 /* TodoListAppDelegate.h */, 73 | 1D3623250D0F684500981E51 /* TodoListAppDelegate.m */, 74 | 28D7ACF60DDB3853001CB0EB /* TodoListViewController.h */, 75 | 28D7ACF70DDB3853001CB0EB /* TodoListViewController.m */, 76 | 01457AE8117723E2005BBF82 /* NewItemViewController.h */, 77 | 01457AE9117723E2005BBF82 /* NewItemViewController.m */, 78 | ); 79 | name = "View Controllers"; 80 | sourceTree = ""; 81 | }; 82 | 01457AF41177269B005BBF82 /* Model */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | B2CE7D5613E172A700AB7DB4 /* TodoList.h */, 86 | B2CE7D5513E172A700AB7DB4 /* TodoList.m */, 87 | B2CE7D5213E1729C00AB7DB4 /* TodoItem.h */, 88 | B2CE7D5313E1729C00AB7DB4 /* TodoItem.m */, 89 | ); 90 | name = Model; 91 | sourceTree = ""; 92 | }; 93 | 01864D4A1861E2D00081685A /* FastCoder */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 01864D4B1861E2D00081685A /* FastCoder.h */, 97 | 01864D4C1861E2D00081685A /* FastCoder.m */, 98 | ); 99 | name = FastCoder; 100 | path = ../Libraries/FastCoder; 101 | sourceTree = ""; 102 | }; 103 | 080E96DDFE201D6D7F000001 /* Classes */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 01457AF311772690005BBF82 /* View Controllers */, 107 | 01457AF41177269B005BBF82 /* Model */, 108 | ); 109 | path = Classes; 110 | sourceTree = ""; 111 | }; 112 | 19C28FACFE9D520D11CA2CBB /* Products */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 1D6058910D05DD3D006BFB54 /* FCTodoList.app */, 116 | ); 117 | name = Products; 118 | sourceTree = ""; 119 | }; 120 | 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { 121 | isa = PBXGroup; 122 | children = ( 123 | 01864D4A1861E2D00081685A /* FastCoder */, 124 | B25BC0F8146AA0FB00008FB3 /* BaseModel */, 125 | 080E96DDFE201D6D7F000001 /* Classes */, 126 | 29B97315FDCFA39411CA2CEA /* Other Sources */, 127 | 29B97317FDCFA39411CA2CEA /* Resources */, 128 | 29B97323FDCFA39411CA2CEA /* Frameworks */, 129 | 19C28FACFE9D520D11CA2CBB /* Products */, 130 | ); 131 | name = CustomTemplate; 132 | sourceTree = ""; 133 | }; 134 | 29B97315FDCFA39411CA2CEA /* Other Sources */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 32CA4F630368D1EE00C91783 /* FCTodoList_Prefix.pch */, 138 | 29B97316FDCFA39411CA2CEA /* main.m */, 139 | ); 140 | name = "Other Sources"; 141 | sourceTree = ""; 142 | }; 143 | 29B97317FDCFA39411CA2CEA /* Resources */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 01CDB20B161133F600B929AD /* Default-568h@2x.png */, 147 | 2899E5210DE3E06400AC0155 /* TodoListViewController.xib */, 148 | 01457AEA117723E2005BBF82 /* NewItemViewController.xib */, 149 | 28AD733E0D9D9553002E5188 /* MainWindow.xib */, 150 | 8D1107310486CEB800E47090 /* FCTodoList-Info.plist */, 151 | ); 152 | name = Resources; 153 | sourceTree = ""; 154 | }; 155 | 29B97323FDCFA39411CA2CEA /* Frameworks */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, 159 | 1D30AB110D05D00D00671497 /* Foundation.framework */, 160 | 288765A40DF7441C002DB57D /* CoreGraphics.framework */, 161 | ); 162 | name = Frameworks; 163 | sourceTree = ""; 164 | }; 165 | B25BC0F8146AA0FB00008FB3 /* BaseModel */ = { 166 | isa = PBXGroup; 167 | children = ( 168 | B25BC0F9146AA0FB00008FB3 /* BaseModel.h */, 169 | B25BC0FA146AA0FB00008FB3 /* BaseModel.m */, 170 | ); 171 | name = BaseModel; 172 | path = ../../BaseModel; 173 | sourceTree = ""; 174 | }; 175 | /* End PBXGroup section */ 176 | 177 | /* Begin PBXNativeTarget section */ 178 | 1D6058900D05DD3D006BFB54 /* FCTodoList */ = { 179 | isa = PBXNativeTarget; 180 | buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "FCTodoList" */; 181 | buildPhases = ( 182 | 1D60588D0D05DD3D006BFB54 /* Resources */, 183 | 1D60588E0D05DD3D006BFB54 /* Sources */, 184 | 1D60588F0D05DD3D006BFB54 /* Frameworks */, 185 | ); 186 | buildRules = ( 187 | ); 188 | dependencies = ( 189 | ); 190 | name = FCTodoList; 191 | productName = TodoList1; 192 | productReference = 1D6058910D05DD3D006BFB54 /* FCTodoList.app */; 193 | productType = "com.apple.product-type.application"; 194 | }; 195 | /* End PBXNativeTarget section */ 196 | 197 | /* Begin PBXProject section */ 198 | 29B97313FDCFA39411CA2CEA /* Project object */ = { 199 | isa = PBXProject; 200 | attributes = { 201 | LastUpgradeCheck = 0900; 202 | }; 203 | buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "FCTodoList" */; 204 | compatibilityVersion = "Xcode 3.2"; 205 | developmentRegion = English; 206 | hasScannedForEncodings = 1; 207 | knownRegions = ( 208 | English, 209 | Japanese, 210 | French, 211 | German, 212 | ); 213 | mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; 214 | projectDirPath = ""; 215 | projectRoot = ""; 216 | targets = ( 217 | 1D6058900D05DD3D006BFB54 /* FCTodoList */, 218 | ); 219 | }; 220 | /* End PBXProject section */ 221 | 222 | /* Begin PBXResourcesBuildPhase section */ 223 | 1D60588D0D05DD3D006BFB54 /* Resources */ = { 224 | isa = PBXResourcesBuildPhase; 225 | buildActionMask = 2147483647; 226 | files = ( 227 | 28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */, 228 | 2899E5220DE3E06400AC0155 /* TodoListViewController.xib in Resources */, 229 | 01457AEC117723E2005BBF82 /* NewItemViewController.xib in Resources */, 230 | 01CDB20C161133F600B929AD /* Default-568h@2x.png in Resources */, 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | /* End PBXResourcesBuildPhase section */ 235 | 236 | /* Begin PBXSourcesBuildPhase section */ 237 | 1D60588E0D05DD3D006BFB54 /* Sources */ = { 238 | isa = PBXSourcesBuildPhase; 239 | buildActionMask = 2147483647; 240 | files = ( 241 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */, 242 | 01864D4D1861E2D00081685A /* FastCoder.m in Sources */, 243 | 1D3623260D0F684500981E51 /* TodoListAppDelegate.m in Sources */, 244 | 28D7ACF80DDB3853001CB0EB /* TodoListViewController.m in Sources */, 245 | 01457AEB117723E2005BBF82 /* NewItemViewController.m in Sources */, 246 | B2CE7D5413E1729C00AB7DB4 /* TodoItem.m in Sources */, 247 | B2CE7D5713E172A700AB7DB4 /* TodoList.m in Sources */, 248 | B25BC0FB146AA0FB00008FB3 /* BaseModel.m in Sources */, 249 | ); 250 | runOnlyForDeploymentPostprocessing = 0; 251 | }; 252 | /* End PBXSourcesBuildPhase section */ 253 | 254 | /* Begin XCBuildConfiguration section */ 255 | 1D6058940D05DD3E006BFB54 /* Debug */ = { 256 | isa = XCBuildConfiguration; 257 | buildSettings = { 258 | ALWAYS_SEARCH_USER_PATHS = NO; 259 | CLANG_ENABLE_OBJC_ARC = YES; 260 | COPY_PHASE_STRIP = NO; 261 | GCC_DYNAMIC_NO_PIC = NO; 262 | GCC_OPTIMIZATION_LEVEL = 0; 263 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 264 | GCC_PREFIX_HEADER = FCTodoList_Prefix.pch; 265 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 266 | INFOPLIST_FILE = "FCTodoList-Info.plist"; 267 | PRODUCT_BUNDLE_IDENTIFIER = "com.charcoaldesign.${PRODUCT_NAME:rfc1034identifier}"; 268 | PRODUCT_NAME = FCTodoList; 269 | SDKROOT = iphoneos; 270 | }; 271 | name = Debug; 272 | }; 273 | 1D6058950D05DD3E006BFB54 /* Release */ = { 274 | isa = XCBuildConfiguration; 275 | buildSettings = { 276 | ALWAYS_SEARCH_USER_PATHS = NO; 277 | CLANG_ENABLE_OBJC_ARC = YES; 278 | COPY_PHASE_STRIP = YES; 279 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 280 | GCC_PREFIX_HEADER = FCTodoList_Prefix.pch; 281 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 282 | INFOPLIST_FILE = "FCTodoList-Info.plist"; 283 | PRODUCT_BUNDLE_IDENTIFIER = "com.charcoaldesign.${PRODUCT_NAME:rfc1034identifier}"; 284 | PRODUCT_NAME = FCTodoList; 285 | }; 286 | name = Release; 287 | }; 288 | C01FCF4F08A954540054247B /* Debug */ = { 289 | isa = XCBuildConfiguration; 290 | buildSettings = { 291 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 292 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 293 | CLANG_WARN_BOOL_CONVERSION = YES; 294 | CLANG_WARN_COMMA = YES; 295 | CLANG_WARN_CONSTANT_CONVERSION = YES; 296 | CLANG_WARN_EMPTY_BODY = YES; 297 | CLANG_WARN_ENUM_CONVERSION = YES; 298 | CLANG_WARN_INFINITE_RECURSION = YES; 299 | CLANG_WARN_INT_CONVERSION = YES; 300 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 301 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 302 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 303 | CLANG_WARN_STRICT_PROTOTYPES = YES; 304 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 305 | CLANG_WARN_UNREACHABLE_CODE = YES; 306 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 307 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 308 | ENABLE_STRICT_OBJC_MSGSEND = YES; 309 | ENABLE_TESTABILITY = YES; 310 | GCC_C_LANGUAGE_STANDARD = c99; 311 | GCC_NO_COMMON_BLOCKS = YES; 312 | GCC_TREAT_WARNINGS_AS_ERRORS = YES; 313 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 314 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 315 | GCC_WARN_UNDECLARED_SELECTOR = YES; 316 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 317 | GCC_WARN_UNUSED_FUNCTION = YES; 318 | GCC_WARN_UNUSED_VARIABLE = YES; 319 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 320 | ONLY_ACTIVE_ARCH = YES; 321 | RUN_CLANG_STATIC_ANALYZER = YES; 322 | SDKROOT = iphoneos; 323 | }; 324 | name = Debug; 325 | }; 326 | C01FCF5008A954540054247B /* Release */ = { 327 | isa = XCBuildConfiguration; 328 | buildSettings = { 329 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 330 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 331 | CLANG_WARN_BOOL_CONVERSION = YES; 332 | CLANG_WARN_COMMA = YES; 333 | CLANG_WARN_CONSTANT_CONVERSION = YES; 334 | CLANG_WARN_EMPTY_BODY = YES; 335 | CLANG_WARN_ENUM_CONVERSION = YES; 336 | CLANG_WARN_INFINITE_RECURSION = YES; 337 | CLANG_WARN_INT_CONVERSION = YES; 338 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 339 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 340 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 341 | CLANG_WARN_STRICT_PROTOTYPES = YES; 342 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 343 | CLANG_WARN_UNREACHABLE_CODE = YES; 344 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 345 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 346 | ENABLE_STRICT_OBJC_MSGSEND = YES; 347 | GCC_C_LANGUAGE_STANDARD = c99; 348 | GCC_NO_COMMON_BLOCKS = YES; 349 | GCC_TREAT_WARNINGS_AS_ERRORS = YES; 350 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 351 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 352 | GCC_WARN_UNDECLARED_SELECTOR = YES; 353 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 354 | GCC_WARN_UNUSED_FUNCTION = YES; 355 | GCC_WARN_UNUSED_VARIABLE = YES; 356 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 357 | RUN_CLANG_STATIC_ANALYZER = YES; 358 | SDKROOT = iphoneos; 359 | }; 360 | name = Release; 361 | }; 362 | /* End XCBuildConfiguration section */ 363 | 364 | /* Begin XCConfigurationList section */ 365 | 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "FCTodoList" */ = { 366 | isa = XCConfigurationList; 367 | buildConfigurations = ( 368 | 1D6058940D05DD3E006BFB54 /* Debug */, 369 | 1D6058950D05DD3E006BFB54 /* Release */, 370 | ); 371 | defaultConfigurationIsVisible = 0; 372 | defaultConfigurationName = Release; 373 | }; 374 | C01FCF4E08A954540054247B /* Build configuration list for PBXProject "FCTodoList" */ = { 375 | isa = XCConfigurationList; 376 | buildConfigurations = ( 377 | C01FCF4F08A954540054247B /* Debug */, 378 | C01FCF5008A954540054247B /* Release */, 379 | ); 380 | defaultConfigurationIsVisible = 0; 381 | defaultConfigurationName = Release; 382 | }; 383 | /* End XCConfigurationList section */ 384 | }; 385 | rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; 386 | } 387 | -------------------------------------------------------------------------------- /Examples/FCTodoList/FCTodoList.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Examples/FCTodoList/FCTodoList.xcodeproj/xcshareddata/xcschemes/HRTodoList.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 56 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 75 | 77 | 83 | 84 | 85 | 86 | 88 | 89 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /Examples/FCTodoList/FCTodoList_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'TodoList1' target in the 'TodoList1' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /Examples/FCTodoList/MainWindow.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Examples/FCTodoList/TodoListViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Examples/FCTodoList/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TodoList1 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright Charcoal Design 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) { 12 | 13 | @autoreleasepool 14 | { 15 | return UIApplicationMain(argc, argv, nil, nil); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Examples/HRTodoList/Classes/NewItemViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NewItemViewController.h 3 | // TodoList4 4 | // 5 | // Created by Nick Lockwood on 15/04/2010. 6 | // Copyright 2010 Charcoal Design. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class TodoItem; 12 | 13 | @interface NewItemViewController : UIViewController 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Examples/HRTodoList/Classes/NewItemViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // NewItemViewController.m 3 | // TodoList4 4 | // 5 | // Created by Nick Lockwood on 15/04/2010. 6 | // Copyright 2010 Charcoal Design. All rights reserved. 7 | // 8 | 9 | #import "NewItemViewController.h" 10 | #import "TodoList.h" 11 | #import "TodoItem.h" 12 | 13 | 14 | @interface NewItemViewController() 15 | 16 | @property (nonatomic, strong) TodoItem *item; 17 | 18 | @end 19 | 20 | 21 | @implementation NewItemViewController 22 | 23 | @synthesize item; 24 | 25 | #pragma mark - 26 | #pragma mark UITextViewDelegate methods 27 | 28 | - (void)textViewDidChange:(UITextView *)textView 29 | { 30 | if (item == nil) 31 | { 32 | //create a new TodoItem and add to list 33 | self.item = [TodoItem instanceWithLabel:textView.text]; 34 | [[TodoList sharedInstance].items addObject:item]; 35 | } 36 | else 37 | { 38 | //update the TodoItem 39 | item.label = textView.text; 40 | } 41 | 42 | //save the item 43 | [item save]; 44 | } 45 | 46 | #pragma mark - 47 | #pragma mark Cleanup 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Examples/HRTodoList/Classes/NewItemViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Examples/HRTodoList/Classes/TodoItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // TodoItem.h 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 28/07/2011. 6 | // Copyright 2011 Charcoal Design. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | #import "BaseModel.h" 12 | 13 | 14 | @interface TodoItem : BaseModel 15 | 16 | @property (nonatomic, copy) NSString *label; 17 | @property (nonatomic, assign) BOOL checked; 18 | 19 | + (instancetype)instanceWithLabel:(NSString *)label; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Examples/HRTodoList/Classes/TodoItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // TodoItem.m 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 28/07/2011. 6 | // Copyright 2011 Charcoal Design. All rights reserved. 7 | // 8 | 9 | #import "TodoItem.h" 10 | #import "TodoList.h" 11 | 12 | 13 | @implementation TodoItem 14 | 15 | + (instancetype)instanceWithLabel:(NSString *)label 16 | { 17 | TodoItem *instance = [self instance]; 18 | instance.label = label; 19 | return instance; 20 | } 21 | 22 | - (BOOL)save 23 | { 24 | //save the todolist 25 | return [[TodoList sharedInstance] save]; 26 | } 27 | 28 | //NOTE: no need to implement the NSCoding methods 29 | //BaseModel does that for us automagically 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Examples/HRTodoList/Classes/TodoList.h: -------------------------------------------------------------------------------- 1 | // 2 | // TodoList.h 3 | // TodoListExample 4 | // 5 | // Created by Nick Lockwood on 28/07/2011. 6 | // Copyright 2011 Charcoal Design. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | #import "BaseModel.h" 12 | 13 | 14 | @interface TodoList : BaseModel 15 | 16 | @property (nonatomic, strong) NSMutableArray *items; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Examples/HRTodoList/Classes/TodoList.m: -------------------------------------------------------------------------------- 1 | // 2 | // TodoList.m 3 | // TodoListExample 4 | // 5 | // Created by Nick Lockwood on 28/07/2011. 6 | // Copyright 2011 Charcoal Design. All rights reserved. 7 | // 8 | 9 | #import "TodoList.h" 10 | #import "TodoItem.h" 11 | 12 | 13 | @implementation TodoList 14 | 15 | - (void)setUp 16 | { 17 | self.items = [NSMutableArray array]; 18 | } 19 | 20 | + (BMFileFormat)saveFormat 21 | { 22 | return BMFileFormatHRCodedJSON; 23 | } 24 | 25 | //NOTE: no need to implement the NSCoding methods 26 | //BaseModel does that for us automagically 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Examples/HRTodoList/Classes/TodoListAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // TodoListAppDelegate.h 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright Charcoal Design 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface TodoListAppDelegate : NSObject 13 | 14 | @property (nonatomic, strong) IBOutlet UIWindow *window; 15 | @property (nonatomic, strong) IBOutlet UIViewController *viewController; 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /Examples/HRTodoList/Classes/TodoListAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // TodoListAppDelegate.m 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright Charcoal Design 2010. All rights reserved. 7 | // 8 | 9 | #import "TodoListAppDelegate.h" 10 | #import "HRCoder.h" 11 | 12 | 13 | @implementation TodoListAppDelegate 14 | 15 | - (void)applicationDidFinishLaunching:(UIApplication *)application 16 | { 17 | [self.window makeKeyAndVisible]; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Examples/HRTodoList/Classes/TodoListViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TodoListViewController.h 3 | // TodoList 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright Charcoal Design 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TodoListViewController : UITableViewController 12 | 13 | - (IBAction)createNewItem; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /Examples/HRTodoList/Classes/TodoListViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TodoList1ViewController.m 3 | // TodoList1 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright AKQA 2010. All rights reserved. 7 | // 8 | 9 | #import "TodoListViewController.h" 10 | #import "NewItemViewController.h" 11 | #import "TodoItem.h" 12 | #import "TodoList.h" 13 | 14 | 15 | @implementation TodoListViewController 16 | 17 | - (void)viewDidLoad 18 | { 19 | [super viewDidLoad]; 20 | self.navigationItem.leftBarButtonItem = self.editButtonItem; 21 | self.clearsSelectionOnViewWillAppear = YES; 22 | } 23 | 24 | - (void)viewWillAppear:(BOOL)animated 25 | { 26 | [super viewWillAppear:YES]; 27 | [self.tableView reloadData]; 28 | } 29 | 30 | - (IBAction)createNewItem 31 | { 32 | UIViewController *viewController = [[NewItemViewController alloc] init]; 33 | [self.navigationController pushViewController:viewController animated:YES]; 34 | } 35 | 36 | #pragma mark - 37 | #pragma mark UITableViewDelegate methods 38 | 39 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 40 | { 41 | TodoItem *item = [[TodoList sharedInstance].items objectAtIndex:indexPath.row]; 42 | item.checked = !item.checked; 43 | [item save]; 44 | 45 | [tableView reloadData]; 46 | } 47 | 48 | - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 49 | { 50 | return UITableViewCellEditingStyleDelete; 51 | } 52 | 53 | - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 54 | { 55 | [[TodoList sharedInstance].items removeObjectAtIndex:indexPath.row]; 56 | [[TodoList sharedInstance] save]; 57 | 58 | [tableView reloadData]; 59 | } 60 | 61 | #pragma mark - 62 | #pragma mark UITableViewDataSource methods 63 | 64 | - (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section 65 | { 66 | return [[TodoList sharedInstance].items count]; 67 | } 68 | 69 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 70 | { 71 | static NSString *cellType = @"Cell"; 72 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellType]; 73 | if (cell == nil) 74 | { 75 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellType]; 76 | } 77 | 78 | TodoItem *item = [[TodoList sharedInstance].items objectAtIndex:indexPath.row]; 79 | cell.textLabel.text = item.label; 80 | if (item.checked) { 81 | cell.accessoryType = UITableViewCellAccessoryCheckmark; 82 | } else { 83 | cell.accessoryType = UITableViewCellAccessoryNone; 84 | } 85 | 86 | return cell; 87 | } 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /Examples/HRTodoList/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicklockwood/BaseModel/c503c8f6ce0a826e3c27ce500686eefd1fe0d52a/Examples/HRTodoList/Default-568h@2x.png -------------------------------------------------------------------------------- /Examples/HRTodoList/HRTodoList-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | 30 | 31 | -------------------------------------------------------------------------------- /Examples/HRTodoList/HRTodoList.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Examples/HRTodoList/HRTodoList.xcodeproj/xcshareddata/xcschemes/HRTodoList.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 56 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 75 | 77 | 83 | 84 | 85 | 86 | 88 | 89 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /Examples/HRTodoList/HRTodoList_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'TodoList1' target in the 'TodoList1' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /Examples/HRTodoList/MainWindow.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Examples/HRTodoList/TodoList.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $class 6 | TodoList 7 | items 8 | 9 | 10 | $class 11 | TodoItem 12 | label 13 | Do washing 14 | 15 | 16 | $class 17 | TodoItem 18 | label 19 | Mow lawn 20 | 21 | 22 | $class 23 | TodoItem 24 | label 25 | Write an open source library 26 | 27 | 28 | $class 29 | TodoItem 30 | label 31 | Feed the cat 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Examples/HRTodoList/TodoListViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Examples/HRTodoList/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TodoList1 4 | // 5 | // Created by Nick Lockwood on 08/04/2010. 6 | // Copyright Charcoal Design 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) { 12 | 13 | @autoreleasepool { 14 | int retVal = UIApplicationMain(argc, argv, nil, nil); 15 | return retVal; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Examples/Libraries/CryptoCoding/CryptoCoding.h: -------------------------------------------------------------------------------- 1 | // 2 | // CryptoCoding.h 3 | // 4 | // Version 1.1.1 5 | // 6 | // Created by Nick Lockwood on 23/09/2012. 7 | // Copyright (c) 2011 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib License 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/CryptoCoding 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | 34 | #import 35 | 36 | 37 | #pragma GCC diagnostic push 38 | #pragma GCC diagnostic ignored "-Wobjc-missing-property-synthesis" 39 | 40 | 41 | extern NSString *const CryptoCoderErrorDomain; 42 | extern NSString *const CryptoCoderException; 43 | 44 | 45 | extern const float CryptoCodingVersion; 46 | 47 | 48 | @interface NSData (CryptoCoding) 49 | 50 | - (NSData *)AESEncryptedDataWithPassword:(NSString *)password 51 | IV:(NSData **)IV 52 | salt:(NSData **)salt 53 | error:(NSError **)error 54 | version:(float)version; 55 | 56 | - (NSData *)AESDecryptedDataWithPassword:(NSString *)password 57 | IV:(NSData *)IV 58 | salt:(NSData *)salt 59 | error:(NSError **)error 60 | version:(float)version; 61 | @end 62 | 63 | 64 | @interface CryptoArchive : NSObject 65 | 66 | @property (nonatomic, strong, readonly) NSData *iv; 67 | @property (nonatomic, strong, readonly) NSData *salt; 68 | @property (nonatomic, strong, readonly) NSData *cypher; 69 | @property (nonatomic, strong, readonly) Class rootObjectClass; 70 | @property (nonatomic, assign, readonly) float version; 71 | 72 | - (instancetype)initWithRootObject:(id)rootObject password:(NSString *)password; 73 | - (id)unarchiveRootObjectWithPassword:(NSString *)password; 74 | 75 | @end 76 | 77 | 78 | @protocol CryptoCoding 79 | 80 | + (NSString *)CCPassword; 81 | 82 | @end 83 | 84 | 85 | @interface CryptoCoder : NSObject 86 | 87 | + (id)unarchiveObjectWithData:(NSData *)data; 88 | + (id)unarchiveObjectWithFile:(NSString *)path; 89 | + (NSData *)archivedDataWithRootObject:(id)rootObject; 90 | + (BOOL)archiveRootObject:(id)rootObject toFile:(NSString *)path; 91 | 92 | + (void)setClassName:(NSString *)codedName forClass:(Class)cls; 93 | + (NSString *)classNameForClass:(Class)cls; 94 | + (void)setClass:(Class)cls forClassName:(NSString *)codedName; 95 | + (Class)classForClassName:(NSString *)codedName; 96 | 97 | @end 98 | 99 | 100 | #pragma GCC diagnostic pop 101 | 102 | -------------------------------------------------------------------------------- /Examples/Libraries/CryptoCoding/CryptoCoding.m: -------------------------------------------------------------------------------- 1 | // 2 | // CryptoCoding.m 3 | // 4 | // Version 1.1.1 5 | // 6 | // Created by Nick Lockwood on 23/09/2012. 7 | // Copyright (c) 2011 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib License 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/CryptoCoding 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | #import "CryptoCoding.h" 34 | #import 35 | #import 36 | 37 | 38 | #pragma clang diagnostic ignored "-Wobjc-missing-property-synthesis" 39 | #pragma clang diagnostic ignored "-Wnullable-to-nonnull-conversion" 40 | #pragma clang diagnostic ignored "-Wpartial-availability" 41 | #pragma clang diagnostic ignored "-Wdirect-ivar-access" 42 | #pragma clang diagnostic ignored "-Wdouble-promotion" 43 | #pragma clang diagnostic ignored "-Wfloat-conversion" 44 | #pragma clang diagnostic ignored "-Wgnu" 45 | 46 | 47 | #import 48 | #if !__has_feature(objc_arc) 49 | #error This class requires automatic reference counting 50 | #endif 51 | 52 | 53 | NSString *const CryptoCoderErrorDomain = @"CryptoCoderErrorDomain"; 54 | NSString *const CryptoCoderException = @"CryptoCoderException"; 55 | 56 | #if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0) || \ 57 | (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_7) 58 | 59 | const float CryptoCodingVersion = 1.0f; 60 | 61 | #else 62 | 63 | const float CryptoCodingVersion = 2.0f; 64 | 65 | #endif 66 | 67 | 68 | @implementation NSData (CryptoCoding) 69 | 70 | //based on blog post by Rob Napier: http://robnapier.net/blog/aes-commoncrypto-564 71 | 72 | + (NSData *)AESKeyWithPassword:(NSString *)password salt:(NSData *)salt error:(__autoreleasing NSError **)error version:(float)version 73 | { 74 | if ((version ?: CryptoCodingVersion) >= 2.0f) 75 | { 76 | 77 | #if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0) || \ 78 | (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_7) 79 | 80 | //generate key using CCKeyDerivationPBKDF 81 | NSMutableData *key = [NSMutableData dataWithLength:kCCKeySizeAES128]; 82 | int result = CCKeyDerivationPBKDF(kCCPBKDF2, // algorithm 83 | password.UTF8String, // password 84 | [password lengthOfBytesUsingEncoding:NSUTF8StringEncoding], // password length 85 | salt.bytes, // salt 86 | salt.length, // salt length 87 | kCCPRFHmacAlgSHA1, // PRF 88 | 1024, // rounds 89 | key.mutableBytes, // derived key 90 | key.length); // derived key length 91 | 92 | #else 93 | 94 | //CCKeyDerivationPBKDF is not available on iOS < 5 or Mac OS < 10.7 95 | NSMutableData *key = nil; 96 | int result = kCCUnimplemented; 97 | 98 | #endif 99 | 100 | if (result == kCCSuccess) 101 | { 102 | return key; 103 | } 104 | else 105 | { 106 | if (error) *error = [NSError errorWithDomain:CryptoCoderErrorDomain code:result userInfo:@{NSLocalizedDescriptionKey: @"Could not generate encryption key"}]; 107 | return nil; 108 | } 109 | } 110 | else 111 | { 112 | //use legacy key generation mechanism 113 | NSMutableData *key = [NSMutableData dataWithData:[password dataUsingEncoding:NSUTF8StringEncoding]]; 114 | [key appendData:salt]; 115 | key.length = MAX([key length], CC_MD5_DIGEST_LENGTH); 116 | for (NSInteger i = 0; i < 1024; i++) 117 | { 118 | CC_MD5(key.bytes, (CC_LONG)key.length, key.mutableBytes); 119 | [key setLength:CC_MD5_DIGEST_LENGTH]; 120 | } 121 | key.length = kCCKeySizeAES128; 122 | return key; 123 | } 124 | } 125 | 126 | - (NSData *)AESEncryptedDataWithPassword:(NSString *)password IV:(__autoreleasing NSData **)IV salt:(__autoreleasing NSData **)salt error:(__autoreleasing NSError **)error version:(float)version 127 | { 128 | //generate IV if not supplied 129 | if (*IV == nil) 130 | { 131 | *IV = [NSMutableData dataWithLength:kCCBlockSizeAES128]; 132 | if (SecRandomCopyBytes(kSecRandomDefault, kCCBlockSizeAES128, ((NSMutableData *)*IV).mutableBytes)) 133 | { 134 | if (error) *error = [NSError errorWithDomain:CryptoCoderErrorDomain code:errno userInfo:@{NSLocalizedDescriptionKey: @"Could not generate initialization vector value"}]; 135 | return nil; 136 | } 137 | } 138 | 139 | //generate salt if not supplied 140 | if (*salt == nil) 141 | { 142 | *salt = [NSMutableData dataWithLength:8]; 143 | if (SecRandomCopyBytes(kSecRandomDefault, [*salt length], ((NSMutableData *)*salt).mutableBytes)) 144 | { 145 | if (error) *error = [NSError errorWithDomain:CryptoCoderErrorDomain code:errno userInfo:@{NSLocalizedDescriptionKey: @"Could not generate salt value"}]; 146 | return nil; 147 | } 148 | } 149 | 150 | //generate key 151 | NSData *key = [NSData AESKeyWithPassword:password salt:*salt error:error version:version]; 152 | if (!key) return nil; 153 | 154 | //encrypt the data 155 | size_t length = 0; 156 | NSMutableData *cypher = [NSMutableData dataWithLength:self.length + kCCBlockSizeAES128]; 157 | CCCryptorStatus result = CCCrypt(kCCEncrypt, // operation 158 | kCCAlgorithmAES128, // algorithm 159 | kCCOptionPKCS7Padding, // options 160 | key.bytes, // key 161 | key.length, // key length 162 | (*IV).bytes, // iv 163 | self.bytes, // input 164 | self.length, // data length, 165 | cypher.mutableBytes, // ouput 166 | cypher.length, // output max length 167 | &length); // output length 168 | if (result == kCCSuccess) 169 | { 170 | cypher.length = length; 171 | } 172 | else 173 | { 174 | if (error) *error = [NSError errorWithDomain:CryptoCoderErrorDomain code:result userInfo:@{NSLocalizedDescriptionKey: @"Could not encrypt data"}]; 175 | return nil; 176 | } 177 | return cypher; 178 | } 179 | 180 | - (NSData *)AESDecryptedDataWithPassword:(NSString *)password IV:(NSData *)IV salt:(NSData *)salt error:(__autoreleasing NSError **)error version:(float)version 181 | { 182 | //generate key 183 | NSData *key = [NSData AESKeyWithPassword:password salt:salt error:error version:version]; 184 | 185 | //decrypt the data 186 | size_t length = 0; 187 | NSMutableData *cleartext = [NSMutableData dataWithLength:self.length + kCCBlockSizeAES128]; 188 | CCCryptorStatus result = CCCrypt(kCCDecrypt, // operation 189 | kCCAlgorithmAES128, // algorithm 190 | kCCOptionPKCS7Padding, // options 191 | key.bytes, // key 192 | key.length, // key length 193 | IV.bytes, // iv 194 | self.bytes, // input 195 | self.length, // data length, 196 | cleartext.mutableBytes, // ouput 197 | cleartext.length, // output max length 198 | &length); // output length 199 | if (result == kCCSuccess) 200 | { 201 | cleartext.length = length; 202 | } 203 | else 204 | { 205 | if (error) *error = [NSError errorWithDomain:CryptoCoderErrorDomain code:result userInfo:@{NSLocalizedDescriptionKey: @"Could not decrypt data"}]; 206 | return nil; 207 | } 208 | return cleartext; 209 | } 210 | 211 | @end 212 | 213 | 214 | @interface CryptoArchive () 215 | 216 | @property (nonatomic, strong) NSData *iv; 217 | @property (nonatomic, strong) NSData *salt; 218 | @property (nonatomic, strong) NSData *cypher; 219 | @property (nonatomic, strong) Class rootObjectClass; 220 | @property (nonatomic, assign) float version; 221 | 222 | @end 223 | 224 | 225 | @implementation CryptoArchive 226 | 227 | - (instancetype)initWithRootObject:(id)rootObject password:(NSString *)password 228 | { 229 | if ((self = [self init])) 230 | { 231 | NSData *iv = nil; 232 | NSData *salt = nil; 233 | NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rootObject]; 234 | self.version = CryptoCodingVersion; 235 | self.rootObjectClass = [(NSObject *)rootObject classForCoder]; 236 | self.cypher = [data AESEncryptedDataWithPassword:password IV:&iv salt:&salt error:NULL version:CryptoCodingVersion]; 237 | self.salt = salt; 238 | self.iv = iv; 239 | } 240 | return self; 241 | } 242 | 243 | - (id)unarchiveRootObjectWithPassword:(NSString *)password 244 | { 245 | if (floor(_version) <= CryptoCodingVersion) 246 | { 247 | NSData *data = [_cypher AESDecryptedDataWithPassword:password IV:_iv salt:_salt error:NULL version:_version]; 248 | return [NSKeyedUnarchiver unarchiveObjectWithData:data]; 249 | } 250 | else 251 | { 252 | NSLog(@"Unsupported CryptoArchive version (%f)", _version); 253 | return nil; 254 | } 255 | } 256 | 257 | + (BOOL)supportsSecureCoding 258 | { 259 | return YES; 260 | } 261 | 262 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 263 | { 264 | if ([aDecoder respondsToSelector:@selector(decodeObjectOfClass:forKey:)]) 265 | { 266 | //secure coding 267 | self.iv = [aDecoder decodeObjectOfClass:[NSData class] forKey:@"iv"]; 268 | self.salt = [aDecoder decodeObjectOfClass:[NSData class] forKey:@"salt"]; 269 | self.cypher = [aDecoder decodeObjectOfClass:[NSData class] forKey:@"cypher"]; 270 | self.rootObjectClass = NSClassFromString([aDecoder decodeObjectOfClass:[NSString class] forKey:@"className"]); 271 | self.version = [[aDecoder decodeObjectOfClass:[NSNumber class] forKey:@"version"] floatValue]; 272 | } 273 | else 274 | { 275 | //regular coding 276 | self.iv = [aDecoder decodeObjectForKey:@"iv"]; 277 | self.salt = [aDecoder decodeObjectForKey:@"salt"]; 278 | self.cypher = [aDecoder decodeObjectForKey:@"cypher"]; 279 | self.rootObjectClass = NSClassFromString([aDecoder decodeObjectForKey:@"className"]); 280 | self.version = [[aDecoder decodeObjectForKey:@"version"] floatValue]; 281 | } 282 | return self; 283 | } 284 | 285 | - (void)encodeWithCoder:(NSCoder *)aCoder 286 | { 287 | [aCoder encodeObject:_iv forKey:@"iv"]; 288 | [aCoder encodeObject:_salt forKey:@"salt"]; 289 | [aCoder encodeObject:_cypher forKey:@"cypher"]; 290 | [aCoder encodeObject:NSStringFromClass(_rootObjectClass) forKey:@"className"]; 291 | [aCoder encodeObject:@(_version) forKey:@"version"]; 292 | } 293 | 294 | - (id)copyWithZone:(NSZone *)zone 295 | { 296 | CryptoArchive *copy = [[CryptoArchive allocWithZone:zone] init]; 297 | copy.iv = _iv; 298 | copy.salt = _salt; 299 | copy.cypher = _cypher; 300 | copy.rootObjectClass = _rootObjectClass; 301 | copy.version = _version; 302 | return copy; 303 | } 304 | 305 | - (NSString *)description 306 | { 307 | return [NSString stringWithFormat:@"<%@: %p version=%g>", [self class], (void *)self, _version]; 308 | } 309 | 310 | @end 311 | 312 | 313 | @implementation CryptoCoder 314 | 315 | + (id)unarchiveObjectWithData:(NSData *)data 316 | { 317 | id object = data? [NSKeyedUnarchiver unarchiveObjectWithData:data]: nil; 318 | if ([object isKindOfClass:[CryptoArchive class]]) 319 | { 320 | CryptoArchive *archive = object; 321 | Class class = archive.rootObjectClass; 322 | if ([class respondsToSelector:@selector(CCPassword)]) 323 | { 324 | NSString *password = [class CCPassword]; 325 | object = [archive unarchiveRootObjectWithPassword:password]; 326 | } 327 | else 328 | { 329 | [NSException raise:CryptoCoderException format:@"%@ does not conform to the CryptoCoding protocol", class]; 330 | object = nil; 331 | } 332 | } 333 | return object; 334 | } 335 | 336 | + (id)unarchiveObjectWithFile:(NSString *)path 337 | { 338 | //load the file 339 | return [self unarchiveObjectWithData:[NSData dataWithContentsOfFile:path]]; 340 | } 341 | 342 | + (NSData *)archivedDataWithRootObject:(id)rootObject 343 | { 344 | Class class = [(NSObject *)rootObject classForCoder]; 345 | if ([class respondsToSelector:@selector(CCPassword)]) 346 | { 347 | NSString *password = [class CCPassword]; 348 | CryptoArchive *archive = [[CryptoArchive alloc] initWithRootObject:rootObject password:password]; 349 | return [NSKeyedArchiver archivedDataWithRootObject:archive]; 350 | } 351 | else 352 | { 353 | [NSException raise:CryptoCoderException format:@"%@ does not conform to the CryptoCoding protocol", class]; 354 | return nil; 355 | } 356 | } 357 | 358 | + (BOOL)archiveRootObject:(id)rootObject toFile:(NSString *)path 359 | { 360 | return [[self archivedDataWithRootObject:rootObject] writeToFile:path atomically:YES]; 361 | } 362 | 363 | + (void)setClassName:(NSString *)codedName forClass:(Class)cls 364 | { 365 | [NSKeyedArchiver setClassName:codedName forClass:cls]; 366 | } 367 | 368 | + (NSString *)classNameForClass:(Class)cls 369 | { 370 | return [NSKeyedArchiver classNameForClass:cls]; 371 | } 372 | 373 | + (void)setClass:(Class)cls forClassName:(NSString *)codedName 374 | { 375 | [NSKeyedUnarchiver setClass:cls forClassName:codedName]; 376 | } 377 | 378 | + (Class)classForClassName:(NSString *)codedName 379 | { 380 | return [NSKeyedUnarchiver classForClassName:codedName]; 381 | } 382 | 383 | @end 384 | -------------------------------------------------------------------------------- /Examples/Libraries/FastCoder/FastCoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // FastCoding.h 3 | // 4 | // Version 3.2.2 5 | // 6 | // Created by Nick Lockwood on 09/12/2013. 7 | // Copyright (c) 2013 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib License 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/FastCoding 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | 34 | #import 35 | 36 | 37 | extern NSString *const FastCodingException; 38 | 39 | 40 | @interface NSObject (FastCoding) 41 | 42 | + (NSArray *)fastCodingKeys; 43 | - (id)awakeAfterFastCoding; 44 | - (Class)classForFastCoding; 45 | - (BOOL)preferFastCoding; 46 | 47 | @end 48 | 49 | 50 | @interface FastCoder : NSObject 51 | 52 | + (id)objectWithData:(NSData *)data; 53 | + (id)propertyListWithData:(NSData *)data; 54 | + (NSData *)dataWithRootObject:(id)object; 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /Examples/Libraries/HRCoder/HRCoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // HRCoder.h 3 | // 4 | // Version 1.3.3 5 | // 6 | // Created by Nick Lockwood on 24/04/2012. 7 | // Copyright (c) 2011 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib License 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/HRCoder 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | 34 | #import 35 | 36 | 37 | #pragma GCC diagnostic push 38 | #pragma GCC diagnostic ignored "-Wobjc-missing-property-synthesis" 39 | 40 | 41 | extern NSString *const HRCoderException; 42 | extern NSString *const HRCoderClassNameKey; 43 | extern NSString *const HRCoderRootObjectKey; 44 | extern NSString *const HRCoderObjectAliasKey; 45 | extern NSString *const HRCoderBase64DataKey; 46 | 47 | 48 | typedef NS_ENUM(NSUInteger, HRCoderFormat) 49 | { 50 | HRCoderFormatXML = 0, 51 | HRCoderFormatJSON, 52 | HRCoderFormatBinary, 53 | }; 54 | 55 | 56 | @interface HRCoder : NSCoder 57 | 58 | @property (nonatomic, assign) HRCoderFormat outputFormat; 59 | 60 | + (id)unarchiveObjectWithPlistOrJSON:(id)plistOrJSON; 61 | + (id)unarchiveObjectWithData:(NSData *)data; 62 | + (id)unarchiveObjectWithFile:(NSString *)path; 63 | + (id)archivedPlistWithRootObject:(id)rootObject; 64 | + (id)archivedJSONWithRootObject:(id)rootObject; 65 | + (NSData *)archivedDataWithRootObject:(id)rootObject; 66 | + (BOOL)archiveRootObject:(id)rootObject toFile:(NSString *)path; 67 | 68 | - (id)initForReadingWithData:(NSData *)data; 69 | - (id)initForWritingWithMutableData:(NSMutableData *)data; 70 | - (void)finishDecoding; 71 | - (void)finishEncoding; 72 | 73 | @end 74 | 75 | 76 | #pragma GCC diagnostic pop 77 | -------------------------------------------------------------------------------- /Examples/MacHRAutoTodoList/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MacHRAutoTodoList 4 | // 5 | // Created by Alex Gray on 11/26/12. 6 | // Copyright (c) 2012 Alex Gray. All rights reserved. 7 | // 8 | 9 | 10 | #import "Todos.h" 11 | 12 | @interface AppDelegate : NSObject 13 | 14 | @property (weak) IBOutlet NSTableView *table; 15 | @property (nonatomic) TodoList *todos; 16 | 17 | - (IBAction) newTodo: (id)sender; 18 | - (IBAction) loadFromPlist: (id)sender; 19 | - (IBAction) copyTodo: (id)sender; 20 | - (IBAction) saveTodos: (id)sender; 21 | - (IBAction) deleteAll: (id)sender; 22 | 23 | @end 24 | 25 | -------------------------------------------------------------------------------- /Examples/MacHRAutoTodoList/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // MacHRAutoTodoList 4 | // 5 | // Created by Alex Gray on 11/26/12. 6 | // Copyright (c) 2012 Alex Gray. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface TodoColorCell : NSActionCell 12 | @end 13 | @interface TodoPriorityClickCell : NSActionCell 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | - (TodoList*) todos { return _todos = _todos ?: TodoList.sharedInstance; } 19 | 20 | - (IBAction) deleteAll: (id)s { self.todos.items = [NSMutableArray new]; } 21 | 22 | - (IBAction) saveTodos: (id)s { [TodoList.sharedInstance save]; } 23 | 24 | - (IBAction) copyTodo: (id)s { _table.selectedRowIndexes.count != 0 ? [self.todos copyTodo:self.todos.items[_table.selectedRow]] : nil; } 25 | 26 | - (IBAction) newTodo: (id)s { [self.todos newTodo]; } 27 | 28 | - (IBAction) loadFromPlist: (id)s 29 | { 30 | self.todos = [TodoList instanceWithContentsOfFile:TodoList.resourceFile]; 31 | TodoList.sharedInstance = _todos; 32 | } 33 | 34 | -(void)awakeFromNib 35 | { 36 | ((NSTableColumn*)_table.tableColumns[[_table columnWithIdentifier: @"Status"]]).dataCell = TodoColorCell.new; 37 | ((NSTableColumn*)_table.tableColumns[[_table columnWithIdentifier: @"Priority"]]).dataCell = TodoPriorityClickCell.new; 38 | } 39 | 40 | @end 41 | 42 | /** Custom cells... not directly related to Basemodel, etc... but you can see some ways to access the shared instance, etc */ 43 | 44 | @implementation TodoPriorityClickCell 45 | 46 | - (id) target { return self; } 47 | 48 | - (SEL) action { return @selector( tickPriority ); } 49 | 50 | - (void) tickPriority 51 | { 52 | NSUInteger val = [self.objectValue unsignedIntegerValue]; 53 | ((TodoItem*)TodoList.sharedInstance.items[((NSTableView*)self.controlView).selectedRow]).priority = @( val < 8 ? val + 1 : 0 ); 54 | } 55 | 56 | - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView 57 | { 58 | [NSColor.darkGrayColor set]; 59 | NSRectFill ( cellFrame ); 60 | NSString *string = ((NSNumber*)self.objectValue).stringValue; 61 | NSDictionary *attrs = @{ NSFontAttributeName : [NSFont fontWithName:@"Lucida Grande Bold" size: cellFrame.size.height - 10], NSForegroundColorAttributeName : NSColor.whiteColor }; 62 | NSSize stringSize = [string sizeWithAttributes:attrs]; 63 | [string drawInRect: (NSRect) { NSMidX(cellFrame) - stringSize.width / 2, cellFrame.origin.y + 3, stringSize.width, stringSize.height } withAttributes:attrs]; 64 | } 65 | 66 | @end 67 | 68 | @implementation TodoColorCell 69 | 70 | - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { [(NSColor*)self.objectValue set]; NSRectFill(cellFrame); } 71 | 72 | @end 73 | 74 | -------------------------------------------------------------------------------- /Examples/MacHRAutoTodoList/MacHRAutoTodoList/MacHRTodoList-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2012 Alex Gray. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /Examples/MacHRAutoTodoList/MacHRAutoTodoList/MacHRTodoList-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'MacHRAutoTodoList' target in the 'MacHRAutoTodoList' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | 7 | #import 8 | #import 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /Examples/MacHRAutoTodoList/MacHRAutoTodoList/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Examples/MacHRAutoTodoList/MacHRAutoTodoList/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MacHRAutoTodoList 4 | // 5 | // Created by Alex Gray on 11/26/12. 6 | // Copyright (c) 2012 Alex Gray. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **)argv); 14 | } 15 | -------------------------------------------------------------------------------- /Examples/MacHRAutoTodoList/MacHRAutoTodoList/thatch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicklockwood/BaseModel/c503c8f6ce0a826e3c27ce500686eefd1fe0d52a/Examples/MacHRAutoTodoList/MacHRAutoTodoList/thatch.jpg -------------------------------------------------------------------------------- /Examples/MacHRAutoTodoList/MacHRTodoList.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 01864D491861E0910081685A /* HRCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 01864D481861E0910081685A /* HRCoder.m */; }; 11 | 7B7142EF1663A72200B7661A /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B7142EE1663A72200B7661A /* Cocoa.framework */; }; 12 | 7B7142FB1663A72200B7661A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B7142FA1663A72200B7661A /* main.m */; }; 13 | 7B7143021663A72200B7661A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B7143011663A72200B7661A /* AppDelegate.m */; }; 14 | 7B7143201663AB8100B7661A /* TodoItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B71431C1663AB8000B7661A /* TodoItem.m */; }; 15 | 7B7143221663AB8100B7661A /* TodoList.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B71431E1663AB8000B7661A /* TodoList.m */; }; 16 | 7B7143241663ACB200B7661A /* TodoList.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7B7143231663ACB200B7661A /* TodoList.plist */; }; 17 | 7B71432A1663AFB100B7661A /* BaseModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B7143171663A79800B7661A /* BaseModel.m */; }; 18 | 7B71432D1663AFE300B7661A /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7B71432B1663AFE300B7661A /* MainMenu.xib */; }; 19 | 7B71435616641ABE00B7661A /* thatch.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 7B71435516641ABE00B7661A /* thatch.jpg */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | 01864D471861E0910081685A /* HRCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HRCoder.h; sourceTree = ""; }; 24 | 01864D481861E0910081685A /* HRCoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HRCoder.m; sourceTree = ""; }; 25 | 7B7142EA1663A72200B7661A /* MacHRTodoList.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MacHRTodoList.app; sourceTree = BUILT_PRODUCTS_DIR; }; 26 | 7B7142EE1663A72200B7661A /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 27 | 7B7142F11663A72200B7661A /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 28 | 7B7142F21663A72200B7661A /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; 29 | 7B7142F31663A72200B7661A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 30 | 7B7142F61663A72200B7661A /* MacHRTodoList-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "MacHRTodoList-Info.plist"; sourceTree = ""; }; 31 | 7B7142FA1663A72200B7661A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 32 | 7B7142FC1663A72200B7661A /* MacHRTodoList-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MacHRTodoList-Prefix.pch"; sourceTree = ""; }; 33 | 7B7143001663A72200B7661A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.objj.h; path = AppDelegate.h; sourceTree = ""; }; 34 | 7B7143011663A72200B7661A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 35 | 7B7143161663A79800B7661A /* BaseModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.objj.h; path = BaseModel.h; sourceTree = ""; }; 36 | 7B7143171663A79800B7661A /* BaseModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BaseModel.m; sourceTree = ""; }; 37 | 7B71431B1663AB8000B7661A /* Todos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.objj.h; path = Todos.h; sourceTree = ""; }; 38 | 7B71431C1663AB8000B7661A /* TodoItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TodoItem.m; sourceTree = ""; }; 39 | 7B71431E1663AB8000B7661A /* TodoList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TodoList.m; sourceTree = ""; }; 40 | 7B7143231663ACB200B7661A /* TodoList.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = TodoList.plist; sourceTree = SOURCE_ROOT; }; 41 | 7B71432C1663AFE300B7661A /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; 42 | 7B71435516641ABE00B7661A /* thatch.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = thatch.jpg; sourceTree = ""; }; 43 | /* End PBXFileReference section */ 44 | 45 | /* Begin PBXFrameworksBuildPhase section */ 46 | 7B7142E71663A72200B7661A /* Frameworks */ = { 47 | isa = PBXFrameworksBuildPhase; 48 | buildActionMask = 2147483647; 49 | files = ( 50 | 7B7142EF1663A72200B7661A /* Cocoa.framework in Frameworks */, 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXFrameworksBuildPhase section */ 55 | 56 | /* Begin PBXGroup section */ 57 | 01864D461861E0910081685A /* HRCoder */ = { 58 | isa = PBXGroup; 59 | children = ( 60 | 01864D471861E0910081685A /* HRCoder.h */, 61 | 01864D481861E0910081685A /* HRCoder.m */, 62 | ); 63 | name = HRCoder; 64 | path = ../Libraries/HRCoder; 65 | sourceTree = ""; 66 | }; 67 | 7B7142DF1663A72200B7661A = { 68 | isa = PBXGroup; 69 | children = ( 70 | 01864D461861E0910081685A /* HRCoder */, 71 | 7B7143151663A79800B7661A /* BaseModel */, 72 | 7B7142F51663A72200B7661A /* Supporting Files */, 73 | 7B7143001663A72200B7661A /* AppDelegate.h */, 74 | 7B7143011663A72200B7661A /* AppDelegate.m */, 75 | 7B71431B1663AB8000B7661A /* Todos.h */, 76 | 7B71431C1663AB8000B7661A /* TodoItem.m */, 77 | 7B71431E1663AB8000B7661A /* TodoList.m */, 78 | 7B7143231663ACB200B7661A /* TodoList.plist */, 79 | 7B7142ED1663A72200B7661A /* Frameworks */, 80 | 7B7142EB1663A72200B7661A /* Products */, 81 | ); 82 | sourceTree = ""; 83 | }; 84 | 7B7142EB1663A72200B7661A /* Products */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 7B7142EA1663A72200B7661A /* MacHRTodoList.app */, 88 | ); 89 | name = Products; 90 | sourceTree = ""; 91 | }; 92 | 7B7142ED1663A72200B7661A /* Frameworks */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 7B7142EE1663A72200B7661A /* Cocoa.framework */, 96 | 7B7142F01663A72200B7661A /* Other Frameworks */, 97 | ); 98 | name = Frameworks; 99 | sourceTree = ""; 100 | }; 101 | 7B7142F01663A72200B7661A /* Other Frameworks */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 7B7142F11663A72200B7661A /* AppKit.framework */, 105 | 7B7142F21663A72200B7661A /* CoreData.framework */, 106 | 7B7142F31663A72200B7661A /* Foundation.framework */, 107 | ); 108 | name = "Other Frameworks"; 109 | sourceTree = ""; 110 | }; 111 | 7B7142F51663A72200B7661A /* Supporting Files */ = { 112 | isa = PBXGroup; 113 | children = ( 114 | 7B71435516641ABE00B7661A /* thatch.jpg */, 115 | 7B71432B1663AFE300B7661A /* MainMenu.xib */, 116 | 7B7142F61663A72200B7661A /* MacHRTodoList-Info.plist */, 117 | 7B7142FA1663A72200B7661A /* main.m */, 118 | 7B7142FC1663A72200B7661A /* MacHRTodoList-Prefix.pch */, 119 | ); 120 | name = "Supporting Files"; 121 | path = MacHRAutoTodoList; 122 | sourceTree = ""; 123 | }; 124 | 7B7143151663A79800B7661A /* BaseModel */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 7B7143161663A79800B7661A /* BaseModel.h */, 128 | 7B7143171663A79800B7661A /* BaseModel.m */, 129 | ); 130 | name = BaseModel; 131 | path = ../../BaseModel; 132 | sourceTree = ""; 133 | }; 134 | /* End PBXGroup section */ 135 | 136 | /* Begin PBXNativeTarget section */ 137 | 7B7142E91663A72200B7661A /* MacHRTodoList */ = { 138 | isa = PBXNativeTarget; 139 | buildConfigurationList = 7B7143081663A72200B7661A /* Build configuration list for PBXNativeTarget "MacHRTodoList" */; 140 | buildPhases = ( 141 | 7B7142E61663A72200B7661A /* Sources */, 142 | 7B7142E71663A72200B7661A /* Frameworks */, 143 | 7B7142E81663A72200B7661A /* Resources */, 144 | ); 145 | buildRules = ( 146 | ); 147 | dependencies = ( 148 | ); 149 | name = MacHRTodoList; 150 | productName = MacHRAutoTodoList; 151 | productReference = 7B7142EA1663A72200B7661A /* MacHRTodoList.app */; 152 | productType = "com.apple.product-type.application"; 153 | }; 154 | /* End PBXNativeTarget section */ 155 | 156 | /* Begin PBXProject section */ 157 | 7B7142E11663A72200B7661A /* Project object */ = { 158 | isa = PBXProject; 159 | attributes = { 160 | LastUpgradeCheck = 0900; 161 | ORGANIZATIONNAME = "Alex Gray"; 162 | }; 163 | buildConfigurationList = 7B7142E41663A72200B7661A /* Build configuration list for PBXProject "MacHRTodoList" */; 164 | compatibilityVersion = "Xcode 3.2"; 165 | developmentRegion = English; 166 | hasScannedForEncodings = 0; 167 | knownRegions = ( 168 | en, 169 | ); 170 | mainGroup = 7B7142DF1663A72200B7661A; 171 | productRefGroup = 7B7142EB1663A72200B7661A /* Products */; 172 | projectDirPath = ""; 173 | projectRoot = ""; 174 | targets = ( 175 | 7B7142E91663A72200B7661A /* MacHRTodoList */, 176 | ); 177 | }; 178 | /* End PBXProject section */ 179 | 180 | /* Begin PBXResourcesBuildPhase section */ 181 | 7B7142E81663A72200B7661A /* Resources */ = { 182 | isa = PBXResourcesBuildPhase; 183 | buildActionMask = 2147483647; 184 | files = ( 185 | 7B7143241663ACB200B7661A /* TodoList.plist in Resources */, 186 | 7B71432D1663AFE300B7661A /* MainMenu.xib in Resources */, 187 | 7B71435616641ABE00B7661A /* thatch.jpg in Resources */, 188 | ); 189 | runOnlyForDeploymentPostprocessing = 0; 190 | }; 191 | /* End PBXResourcesBuildPhase section */ 192 | 193 | /* Begin PBXSourcesBuildPhase section */ 194 | 7B7142E61663A72200B7661A /* Sources */ = { 195 | isa = PBXSourcesBuildPhase; 196 | buildActionMask = 2147483647; 197 | files = ( 198 | 7B7142FB1663A72200B7661A /* main.m in Sources */, 199 | 7B7143021663A72200B7661A /* AppDelegate.m in Sources */, 200 | 7B7143201663AB8100B7661A /* TodoItem.m in Sources */, 201 | 01864D491861E0910081685A /* HRCoder.m in Sources */, 202 | 7B7143221663AB8100B7661A /* TodoList.m in Sources */, 203 | 7B71432A1663AFB100B7661A /* BaseModel.m in Sources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | /* End PBXSourcesBuildPhase section */ 208 | 209 | /* Begin PBXVariantGroup section */ 210 | 7B71432B1663AFE300B7661A /* MainMenu.xib */ = { 211 | isa = PBXVariantGroup; 212 | children = ( 213 | 7B71432C1663AFE300B7661A /* en */, 214 | ); 215 | name = MainMenu.xib; 216 | sourceTree = ""; 217 | }; 218 | /* End PBXVariantGroup section */ 219 | 220 | /* Begin XCBuildConfiguration section */ 221 | 7B7143061663A72200B7661A /* Debug */ = { 222 | isa = XCBuildConfiguration; 223 | buildSettings = { 224 | ALWAYS_SEARCH_USER_PATHS = NO; 225 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 226 | CLANG_CXX_LIBRARY = "libc++"; 227 | CLANG_ENABLE_OBJC_ARC = YES; 228 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 229 | CLANG_WARN_BOOL_CONVERSION = YES; 230 | CLANG_WARN_COMMA = YES; 231 | CLANG_WARN_CONSTANT_CONVERSION = YES; 232 | CLANG_WARN_EMPTY_BODY = YES; 233 | CLANG_WARN_ENUM_CONVERSION = YES; 234 | CLANG_WARN_INFINITE_RECURSION = YES; 235 | CLANG_WARN_INT_CONVERSION = YES; 236 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 237 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 238 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 239 | CLANG_WARN_STRICT_PROTOTYPES = YES; 240 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 241 | CLANG_WARN_UNREACHABLE_CODE = YES; 242 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 243 | COPY_PHASE_STRIP = NO; 244 | ENABLE_STRICT_OBJC_MSGSEND = YES; 245 | ENABLE_TESTABILITY = YES; 246 | GCC_C_LANGUAGE_STANDARD = gnu99; 247 | GCC_DYNAMIC_NO_PIC = NO; 248 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 249 | GCC_NO_COMMON_BLOCKS = YES; 250 | GCC_OPTIMIZATION_LEVEL = 0; 251 | GCC_PREPROCESSOR_DEFINITIONS = ( 252 | "DEBUG=1", 253 | "$(inherited)", 254 | ); 255 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 256 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 257 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 258 | GCC_WARN_UNDECLARED_SELECTOR = YES; 259 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 260 | GCC_WARN_UNUSED_FUNCTION = YES; 261 | GCC_WARN_UNUSED_VARIABLE = YES; 262 | MACOSX_DEPLOYMENT_TARGET = 10.8; 263 | ONLY_ACTIVE_ARCH = YES; 264 | SDKROOT = macosx; 265 | }; 266 | name = Debug; 267 | }; 268 | 7B7143071663A72200B7661A /* Release */ = { 269 | isa = XCBuildConfiguration; 270 | buildSettings = { 271 | ALWAYS_SEARCH_USER_PATHS = NO; 272 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 273 | CLANG_CXX_LIBRARY = "libc++"; 274 | CLANG_ENABLE_OBJC_ARC = YES; 275 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 276 | CLANG_WARN_BOOL_CONVERSION = YES; 277 | CLANG_WARN_COMMA = YES; 278 | CLANG_WARN_CONSTANT_CONVERSION = YES; 279 | CLANG_WARN_EMPTY_BODY = YES; 280 | CLANG_WARN_ENUM_CONVERSION = YES; 281 | CLANG_WARN_INFINITE_RECURSION = YES; 282 | CLANG_WARN_INT_CONVERSION = YES; 283 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 284 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 285 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 286 | CLANG_WARN_STRICT_PROTOTYPES = YES; 287 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 288 | CLANG_WARN_UNREACHABLE_CODE = YES; 289 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 290 | COPY_PHASE_STRIP = YES; 291 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 292 | ENABLE_STRICT_OBJC_MSGSEND = YES; 293 | GCC_C_LANGUAGE_STANDARD = gnu99; 294 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 295 | GCC_NO_COMMON_BLOCKS = YES; 296 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 297 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 298 | GCC_WARN_UNDECLARED_SELECTOR = YES; 299 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 300 | GCC_WARN_UNUSED_FUNCTION = YES; 301 | GCC_WARN_UNUSED_VARIABLE = YES; 302 | MACOSX_DEPLOYMENT_TARGET = 10.8; 303 | SDKROOT = macosx; 304 | }; 305 | name = Release; 306 | }; 307 | 7B7143091663A72200B7661A /* Debug */ = { 308 | isa = XCBuildConfiguration; 309 | buildSettings = { 310 | COMBINE_HIDPI_IMAGES = YES; 311 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 312 | GCC_PREFIX_HEADER = "MacHRAutoTodoList/MacHRTodoList-Prefix.pch"; 313 | GCC_TREAT_WARNINGS_AS_ERRORS = YES; 314 | INFOPLIST_FILE = "MacHRAutoTodoList/MacHRTodoList-Info.plist"; 315 | OTHER_LDFLAGS = ( 316 | "-Wall", 317 | "-Wextra", 318 | ); 319 | PRODUCT_BUNDLE_IDENTIFIER = "com.github.mralexgray.${PRODUCT_NAME:rfc1034identifier}"; 320 | PRODUCT_NAME = MacHRTodoList; 321 | VALID_ARCHS = x86_64; 322 | WRAPPER_EXTENSION = app; 323 | }; 324 | name = Debug; 325 | }; 326 | 7B71430A1663A72200B7661A /* Release */ = { 327 | isa = XCBuildConfiguration; 328 | buildSettings = { 329 | COMBINE_HIDPI_IMAGES = YES; 330 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 331 | GCC_PREFIX_HEADER = "MacHRAutoTodoList/MacHRTodoList-Prefix.pch"; 332 | GCC_TREAT_WARNINGS_AS_ERRORS = YES; 333 | INFOPLIST_FILE = "MacHRAutoTodoList/MacHRTodoList-Info.plist"; 334 | OTHER_LDFLAGS = ( 335 | "-Wall", 336 | "-Wextra", 337 | ); 338 | PRODUCT_BUNDLE_IDENTIFIER = "com.github.mralexgray.${PRODUCT_NAME:rfc1034identifier}"; 339 | PRODUCT_NAME = MacHRTodoList; 340 | VALID_ARCHS = x86_64; 341 | WRAPPER_EXTENSION = app; 342 | }; 343 | name = Release; 344 | }; 345 | /* End XCBuildConfiguration section */ 346 | 347 | /* Begin XCConfigurationList section */ 348 | 7B7142E41663A72200B7661A /* Build configuration list for PBXProject "MacHRTodoList" */ = { 349 | isa = XCConfigurationList; 350 | buildConfigurations = ( 351 | 7B7143061663A72200B7661A /* Debug */, 352 | 7B7143071663A72200B7661A /* Release */, 353 | ); 354 | defaultConfigurationIsVisible = 0; 355 | defaultConfigurationName = Release; 356 | }; 357 | 7B7143081663A72200B7661A /* Build configuration list for PBXNativeTarget "MacHRTodoList" */ = { 358 | isa = XCConfigurationList; 359 | buildConfigurations = ( 360 | 7B7143091663A72200B7661A /* Debug */, 361 | 7B71430A1663A72200B7661A /* Release */, 362 | ); 363 | defaultConfigurationIsVisible = 0; 364 | defaultConfigurationName = Release; 365 | }; 366 | /* End XCConfigurationList section */ 367 | }; 368 | rootObject = 7B7142E11663A72200B7661A /* Project object */; 369 | } 370 | -------------------------------------------------------------------------------- /Examples/MacHRAutoTodoList/MacHRTodoList.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Examples/MacHRAutoTodoList/TodoItem.m: -------------------------------------------------------------------------------- 1 | 2 | // TodoItem.m 3 | // TodoList 4 | 5 | // Created by Alex Gray on 11/26/12. 6 | // Part of BaseModel by Nick Lockwood. 7 | 8 | #import "Todos.h" 9 | 10 | 11 | @interface TodoItem () 12 | 13 | @property (readwrite) NSDate *created; 14 | 15 | @end 16 | 17 | 18 | @implementation TodoItem 19 | 20 | - (void)setUp 21 | { 22 | _checked = NO; 23 | _created = [NSDate date]; 24 | _label = [NSString stringWithFormat:@"New todo, created:%@", [_created descriptionWithLocale:nil]]; 25 | _priority = @1; 26 | } 27 | 28 | #pragma - UNUSED INIT METHODS /* ironically, neither of these init methods is actually called... but this is how you do it */ 29 | 30 | + (instancetype)instanceWithLabel:(NSString *)label // sort of like a designated initializer, except you dont need to redo any other init's... 31 | { // just make one with whatever poperties you want to set in one step in your actual init method. 32 | TodoItem *instance = [self instance]; 33 | instance.label = label; 34 | return instance; 35 | } 36 | 37 | + (instancetype)instanceWithObject:(id)object 38 | { 39 | TodoItem *instance = [self instance]; // generic init 40 | for (NSString *key in [object allKeys]) // iterate through dictionary keys and setValue if our instance responds 41 | if ([instance respondsToSelector:NSSelectorFromString([NSString stringWithFormat:@"set%@", [key uppercaseString]])]) 42 | [instance setValue:((NSDictionary*)object)[key] forKey:key]; 43 | return instance; 44 | } 45 | 46 | #pragma readonly properties 47 | 48 | - (NSColor *)color 49 | { 50 | return self.checked ? [NSColor colorWithPatternImage:[NSImage imageNamed:@"thatch"]] : 51 | self.priority.intValue == 1 ? [NSColor colorWithCalibratedRed:0.843 green:0.000 blue:0.119 alpha:1.000] : 52 | self.priority.intValue == 2 ? [NSColor colorWithCalibratedRed:1.000 green:0.861 blue:0.225 alpha:1.000] : 53 | self.priority.intValue == 3 ? [NSColor colorWithCalibratedRed:0.986 green:0.484 blue:0.032 alpha:1.000] : 54 | self.priority.intValue == 4 ? [NSColor colorWithCalibratedRed:0.739 green:0.900 blue:0.000 alpha:1.000] : 55 | self.priority.intValue == 5 ? [NSColor colorWithCalibratedRed:0.369 green:0.630 blue:0.589 alpha:1.000] : 56 | self.priority.intValue == 6 ? [NSColor colorWithCalibratedRed:0.253 green:0.478 blue:0.761 alpha:1.000] : 57 | self.priority.intValue == 7 ? [NSColor colorWithCalibratedRed:0.630 green:0.336 blue:0.576 alpha:1.000] : 58 | [NSColor colorWithCalibratedRed:0.883 green:0.254 blue:0.700 alpha:1.000]; 59 | } 60 | 61 | #pragma KVO junk 62 | 63 | + (NSSet *)keyPathsForValuesAffectingColor 64 | { 65 | return [NSSet setWithArray:@[@"checked", @"priority"]]; 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /Examples/MacHRAutoTodoList/TodoList.m: -------------------------------------------------------------------------------- 1 | 2 | // TodoList.m 3 | // TodoListExample 4 | 5 | // Created by Alex Gray on 11/26/12. 6 | // Part of BaseModel by Nick Lockwood. 7 | 8 | 9 | #import "Todos.h" 10 | 11 | @implementation TodoList 12 | 13 | /* note: we've not implemented the NSCoding methods or setWithArray/Dictionary, etc 14 | because the HRCoder and AutoCoding libraries take care of this for us */ 15 | 16 | - (TodoItem *)newTodo 17 | { 18 | TodoItem *newOne = TodoItem.instance; 19 | [self insertObject:newOne inItemsAtIndex:self.items.count]; // KVO Array insertion trigger. 20 | return newOne; 21 | } 22 | 23 | - (TodoItem *)copyTodo:(TodoItem *)todo; 24 | { 25 | TodoItem *newOne = [todo copy]; 26 | [self insertObject:newOne inItemsAtIndex:self.items.count]; 27 | return newOne; 28 | } 29 | 30 | - (NSUInteger)countOfItems 31 | { 32 | return self.items.count; 33 | } 34 | 35 | - (id)objectInItemsAtIndex:(NSUInteger)index 36 | { 37 | return self.items[index]; 38 | } 39 | 40 | - (void)removeObjectFromItemsAtIndex:(NSUInteger)index 41 | { 42 | [self.items removeObjectAtIndex:index]; 43 | } 44 | 45 | - (void)insertObject:(TodoItem*)todo inItemsAtIndex:(NSUInteger)index 46 | { 47 | [self.items insertObject:todo atIndex:index]; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Examples/MacHRAutoTodoList/TodoList.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | items 6 | 7 | 8 | $class 9 | TodoItem 10 | label 11 | Pay the apple tax. 12 | checked 13 | 14 | priority 15 | 5 16 | 17 | 18 | $class 19 | TodoItem 20 | label 21 | Do washing 22 | priority 23 | 3 24 | 25 | 26 | $class 27 | TodoItem 28 | label 29 | Mow lawn 30 | checked 31 | 32 | priority 33 | 6 34 | 35 | 36 | $class 37 | TodoItem 38 | label 39 | Write an open source library 40 | priority 41 | 4 42 | 43 | 44 | $class 45 | TodoItem 46 | label 47 | Feed the cat 48 | priority 49 | 2 50 | 51 | 52 | $class 53 | TodoItem 54 | label 55 | Make peace with oneself. 56 | checked 57 | 58 | priority 59 | 1 60 | 61 | 62 | $class 63 | TodoList 64 | 65 | 66 | -------------------------------------------------------------------------------- /Examples/MacHRAutoTodoList/Todos.h: -------------------------------------------------------------------------------- 1 | 2 | // TodoItem.h 3 | // TodoList 4 | 5 | // Created by Alex Gray on 11/26/12. 6 | // Part of BaseModel by Nick Lockwood. 7 | 8 | #import "BaseModel.h" 9 | 10 | 11 | @interface TodoItem : BaseModel 12 | 13 | @property (readonly) NSColor *color; 14 | @property (nonatomic, strong) NSString *label; 15 | @property (nonatomic, strong) NSNumber *priority; 16 | @property (nonatomic) BOOL checked; 17 | 18 | @end 19 | 20 | 21 | @interface TodoList : BaseModel 22 | 23 | @property (nonatomic, strong) NSMutableArray *items; 24 | 25 | - (TodoItem *)newTodo; 26 | - (TodoItem *)copyTodo:(TodoItem *)todo; 27 | 28 | // Subclass specific KVO Compliant "items" accessors to trigger NSArrayController updates on inserts / removals. 29 | - (NSUInteger)countOfItems; 30 | - (id)objectInItemsAtIndex:(NSUInteger)index; 31 | - (void)removeObjectFromItemsAtIndex:(NSUInteger)index; 32 | - (void)insertObject:(TodoItem *)todo inItemsAtIndex:(NSUInteger)index; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | BaseModel 2 | 3 | Copyright (C) 2011 Charcoal Design 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 18 | 2. Altered source versions must be plainly marked as such, and must not be 19 | misrepresented as being the original software. 20 | 21 | 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------------- /Tests/UnitTests.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 01244B141934E926000BF3CD /* BaseModelTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 01244B131934E926000BF3CD /* BaseModelTests.m */; }; 11 | 01D28C891907BFC80021C719 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01D28C881907BFC80021C719 /* XCTest.framework */; }; 12 | 01D28C8A1907BFC80021C719 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01D28C6F1907BFC80021C719 /* Foundation.framework */; }; 13 | 01D28C8B1907BFC80021C719 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01D28C731907BFC80021C719 /* UIKit.framework */; }; 14 | 01FE99E019AA27F800C67347 /* BaseModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 01FE99DF19AA27F800C67347 /* BaseModel.m */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 01244B131934E926000BF3CD /* BaseModelTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BaseModelTests.m; sourceTree = ""; }; 19 | 01D28C6F1907BFC80021C719 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 20 | 01D28C711907BFC80021C719 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 21 | 01D28C731907BFC80021C719 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 22 | 01D28C871907BFC80021C719 /* UnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | 01D28C881907BFC80021C719 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 24 | 01D28C901907BFC80021C719 /* UnitTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "UnitTests-Info.plist"; sourceTree = ""; }; 25 | 01FE99DE19AA27F800C67347 /* BaseModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseModel.h; sourceTree = ""; }; 26 | 01FE99DF19AA27F800C67347 /* BaseModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BaseModel.m; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | 01D28C841907BFC80021C719 /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | 01D28C891907BFC80021C719 /* XCTest.framework in Frameworks */, 35 | 01D28C8B1907BFC80021C719 /* UIKit.framework in Frameworks */, 36 | 01D28C8A1907BFC80021C719 /* Foundation.framework in Frameworks */, 37 | ); 38 | runOnlyForDeploymentPostprocessing = 0; 39 | }; 40 | /* End PBXFrameworksBuildPhase section */ 41 | 42 | /* Begin PBXGroup section */ 43 | 01D28C631907BFC80021C719 = { 44 | isa = PBXGroup; 45 | children = ( 46 | 01FE99DD19AA27F800C67347 /* BaseModel */, 47 | 01D28C8E1907BFC80021C719 /* UnitTests */, 48 | 01D28C6E1907BFC80021C719 /* Frameworks */, 49 | 01D28C6D1907BFC80021C719 /* Products */, 50 | ); 51 | sourceTree = ""; 52 | }; 53 | 01D28C6D1907BFC80021C719 /* Products */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | 01D28C871907BFC80021C719 /* UnitTests.xctest */, 57 | ); 58 | name = Products; 59 | sourceTree = ""; 60 | }; 61 | 01D28C6E1907BFC80021C719 /* Frameworks */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | 01D28C6F1907BFC80021C719 /* Foundation.framework */, 65 | 01D28C711907BFC80021C719 /* CoreGraphics.framework */, 66 | 01D28C731907BFC80021C719 /* UIKit.framework */, 67 | 01D28C881907BFC80021C719 /* XCTest.framework */, 68 | ); 69 | name = Frameworks; 70 | sourceTree = ""; 71 | }; 72 | 01D28C8E1907BFC80021C719 /* UnitTests */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 01244B131934E926000BF3CD /* BaseModelTests.m */, 76 | 01D28C8F1907BFC80021C719 /* Supporting Files */, 77 | ); 78 | path = UnitTests; 79 | sourceTree = ""; 80 | }; 81 | 01D28C8F1907BFC80021C719 /* Supporting Files */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | 01D28C901907BFC80021C719 /* UnitTests-Info.plist */, 85 | ); 86 | name = "Supporting Files"; 87 | sourceTree = ""; 88 | }; 89 | 01FE99DD19AA27F800C67347 /* BaseModel */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | 01FE99DE19AA27F800C67347 /* BaseModel.h */, 93 | 01FE99DF19AA27F800C67347 /* BaseModel.m */, 94 | ); 95 | name = BaseModel; 96 | path = ../BaseModel; 97 | sourceTree = ""; 98 | }; 99 | /* End PBXGroup section */ 100 | 101 | /* Begin PBXNativeTarget section */ 102 | 01D28C861907BFC80021C719 /* UnitTests */ = { 103 | isa = PBXNativeTarget; 104 | buildConfigurationList = 01D28C9B1907BFC80021C719 /* Build configuration list for PBXNativeTarget "UnitTests" */; 105 | buildPhases = ( 106 | 01D28C831907BFC80021C719 /* Sources */, 107 | 01D28C841907BFC80021C719 /* Frameworks */, 108 | 01D28C851907BFC80021C719 /* Resources */, 109 | ); 110 | buildRules = ( 111 | ); 112 | dependencies = ( 113 | ); 114 | name = UnitTests; 115 | productName = OSCacheTests; 116 | productReference = 01D28C871907BFC80021C719 /* UnitTests.xctest */; 117 | productType = "com.apple.product-type.bundle.unit-test"; 118 | }; 119 | /* End PBXNativeTarget section */ 120 | 121 | /* Begin PBXProject section */ 122 | 01D28C641907BFC80021C719 /* Project object */ = { 123 | isa = PBXProject; 124 | attributes = { 125 | LastUpgradeCheck = 0900; 126 | ORGANIZATIONNAME = "Charcoal Design"; 127 | TargetAttributes = { 128 | 01D28C861907BFC80021C719 = { 129 | TestTargetID = 01D28C6B1907BFC80021C719; 130 | }; 131 | }; 132 | }; 133 | buildConfigurationList = 01D28C671907BFC80021C719 /* Build configuration list for PBXProject "UnitTests" */; 134 | compatibilityVersion = "Xcode 3.2"; 135 | developmentRegion = English; 136 | hasScannedForEncodings = 0; 137 | knownRegions = ( 138 | en, 139 | ); 140 | mainGroup = 01D28C631907BFC80021C719; 141 | productRefGroup = 01D28C6D1907BFC80021C719 /* Products */; 142 | projectDirPath = ""; 143 | projectRoot = ""; 144 | targets = ( 145 | 01D28C861907BFC80021C719 /* UnitTests */, 146 | ); 147 | }; 148 | /* End PBXProject section */ 149 | 150 | /* Begin PBXResourcesBuildPhase section */ 151 | 01D28C851907BFC80021C719 /* Resources */ = { 152 | isa = PBXResourcesBuildPhase; 153 | buildActionMask = 2147483647; 154 | files = ( 155 | ); 156 | runOnlyForDeploymentPostprocessing = 0; 157 | }; 158 | /* End PBXResourcesBuildPhase section */ 159 | 160 | /* Begin PBXSourcesBuildPhase section */ 161 | 01D28C831907BFC80021C719 /* Sources */ = { 162 | isa = PBXSourcesBuildPhase; 163 | buildActionMask = 2147483647; 164 | files = ( 165 | 01FE99E019AA27F800C67347 /* BaseModel.m in Sources */, 166 | 01244B141934E926000BF3CD /* BaseModelTests.m in Sources */, 167 | ); 168 | runOnlyForDeploymentPostprocessing = 0; 169 | }; 170 | /* End PBXSourcesBuildPhase section */ 171 | 172 | /* Begin XCBuildConfiguration section */ 173 | 01D28C961907BFC80021C719 /* Debug */ = { 174 | isa = XCBuildConfiguration; 175 | buildSettings = { 176 | ALWAYS_SEARCH_USER_PATHS = NO; 177 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 178 | CLANG_CXX_LIBRARY = "libc++"; 179 | CLANG_ENABLE_MODULES = NO; 180 | CLANG_ENABLE_OBJC_ARC = YES; 181 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 182 | CLANG_WARN_BOOL_CONVERSION = YES; 183 | CLANG_WARN_COMMA = YES; 184 | CLANG_WARN_CONSTANT_CONVERSION = YES; 185 | CLANG_WARN_CXX0X_EXTENSIONS = YES; 186 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 187 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 188 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 189 | CLANG_WARN_EMPTY_BODY = YES; 190 | CLANG_WARN_ENUM_CONVERSION = YES; 191 | CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; 192 | CLANG_WARN_INFINITE_RECURSION = YES; 193 | CLANG_WARN_INT_CONVERSION = YES; 194 | CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES; 195 | CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; 196 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 197 | CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; 198 | CLANG_WARN_OBJC_RECEIVER_WEAK = YES; 199 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES; 200 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 201 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 202 | CLANG_WARN_STRICT_PROTOTYPES = YES; 203 | CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; 204 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 205 | CLANG_WARN_UNREACHABLE_CODE = YES; 206 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 207 | CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES; 208 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 209 | COPY_PHASE_STRIP = NO; 210 | ENABLE_STRICT_OBJC_MSGSEND = YES; 211 | ENABLE_TESTABILITY = YES; 212 | GCC_C_LANGUAGE_STANDARD = gnu99; 213 | GCC_DYNAMIC_NO_PIC = NO; 214 | GCC_NO_COMMON_BLOCKS = YES; 215 | GCC_OPTIMIZATION_LEVEL = 0; 216 | GCC_PREPROCESSOR_DEFINITIONS = ( 217 | "DEBUG=1", 218 | "$(inherited)", 219 | ); 220 | GCC_SHORT_ENUMS = YES; 221 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 222 | GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; 223 | GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; 224 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; 225 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 226 | GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; 227 | GCC_WARN_ABOUT_MISSING_NEWLINE = YES; 228 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 229 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 230 | GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; 231 | GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; 232 | GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; 233 | GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES; 234 | GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; 235 | GCC_WARN_PEDANTIC = YES; 236 | GCC_WARN_SHADOW = YES; 237 | GCC_WARN_SIGN_COMPARE = YES; 238 | GCC_WARN_STRICT_SELECTOR_MATCH = YES; 239 | GCC_WARN_UNDECLARED_SELECTOR = YES; 240 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 241 | GCC_WARN_UNKNOWN_PRAGMAS = YES; 242 | GCC_WARN_UNUSED_FUNCTION = YES; 243 | GCC_WARN_UNUSED_LABEL = YES; 244 | GCC_WARN_UNUSED_PARAMETER = YES; 245 | GCC_WARN_UNUSED_VARIABLE = YES; 246 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 247 | ONLY_ACTIVE_ARCH = YES; 248 | SDKROOT = iphoneos; 249 | WARNING_CFLAGS = ( 250 | "-Weverything", 251 | "-Wno-variadic-macros", 252 | "-Wno-gnu-zero-variadic-macro-arguments", 253 | "-Wno-gnu-statement-expression", 254 | "-Wno-sign-compare", 255 | "-Wno-documentation-unknown-command", 256 | ); 257 | }; 258 | name = Debug; 259 | }; 260 | 01D28C971907BFC80021C719 /* Release */ = { 261 | isa = XCBuildConfiguration; 262 | buildSettings = { 263 | ALWAYS_SEARCH_USER_PATHS = NO; 264 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 265 | CLANG_CXX_LIBRARY = "libc++"; 266 | CLANG_ENABLE_MODULES = NO; 267 | CLANG_ENABLE_OBJC_ARC = YES; 268 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 269 | CLANG_WARN_BOOL_CONVERSION = YES; 270 | CLANG_WARN_COMMA = YES; 271 | CLANG_WARN_CONSTANT_CONVERSION = YES; 272 | CLANG_WARN_CXX0X_EXTENSIONS = YES; 273 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 274 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 275 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 276 | CLANG_WARN_EMPTY_BODY = YES; 277 | CLANG_WARN_ENUM_CONVERSION = YES; 278 | CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; 279 | CLANG_WARN_INFINITE_RECURSION = YES; 280 | CLANG_WARN_INT_CONVERSION = YES; 281 | CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES; 282 | CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; 283 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 284 | CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; 285 | CLANG_WARN_OBJC_RECEIVER_WEAK = YES; 286 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES; 287 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 288 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 289 | CLANG_WARN_STRICT_PROTOTYPES = YES; 290 | CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; 291 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 292 | CLANG_WARN_UNREACHABLE_CODE = YES; 293 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 294 | CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES; 295 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 296 | COPY_PHASE_STRIP = YES; 297 | ENABLE_NS_ASSERTIONS = NO; 298 | ENABLE_STRICT_OBJC_MSGSEND = YES; 299 | GCC_C_LANGUAGE_STANDARD = gnu99; 300 | GCC_NO_COMMON_BLOCKS = YES; 301 | GCC_SHORT_ENUMS = YES; 302 | GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; 303 | GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; 304 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; 305 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 306 | GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; 307 | GCC_WARN_ABOUT_MISSING_NEWLINE = YES; 308 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 309 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 310 | GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; 311 | GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; 312 | GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; 313 | GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES; 314 | GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; 315 | GCC_WARN_PEDANTIC = YES; 316 | GCC_WARN_SHADOW = YES; 317 | GCC_WARN_SIGN_COMPARE = YES; 318 | GCC_WARN_STRICT_SELECTOR_MATCH = YES; 319 | GCC_WARN_UNDECLARED_SELECTOR = YES; 320 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 321 | GCC_WARN_UNKNOWN_PRAGMAS = YES; 322 | GCC_WARN_UNUSED_FUNCTION = YES; 323 | GCC_WARN_UNUSED_LABEL = YES; 324 | GCC_WARN_UNUSED_PARAMETER = YES; 325 | GCC_WARN_UNUSED_VARIABLE = YES; 326 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 327 | SDKROOT = iphoneos; 328 | VALIDATE_PRODUCT = YES; 329 | WARNING_CFLAGS = ( 330 | "-Weverything", 331 | "-Wno-variadic-macros", 332 | "-Wno-gnu-zero-variadic-macro-arguments", 333 | "-Wno-gnu-statement-expression", 334 | "-Wno-sign-compare", 335 | "-Wno-documentation-unknown-command", 336 | ); 337 | }; 338 | name = Release; 339 | }; 340 | 01D28C9C1907BFC80021C719 /* Debug */ = { 341 | isa = XCBuildConfiguration; 342 | buildSettings = { 343 | FRAMEWORK_SEARCH_PATHS = ( 344 | "$(inherited)", 345 | "$(DEVELOPER_FRAMEWORKS_DIR)", 346 | ); 347 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 348 | GCC_PREPROCESSOR_DEFINITIONS = ( 349 | "DEBUG=1", 350 | "$(inherited)", 351 | ); 352 | INFOPLIST_FILE = "UnitTests/UnitTests-Info.plist"; 353 | PRODUCT_BUNDLE_IDENTIFIER = "com.charcoaldesign.${PRODUCT_NAME:rfc1034identifier}"; 354 | PRODUCT_NAME = UnitTests; 355 | TEST_HOST = "$(BUNDLE_LOADER)"; 356 | WRAPPER_EXTENSION = xctest; 357 | }; 358 | name = Debug; 359 | }; 360 | 01D28C9D1907BFC80021C719 /* Release */ = { 361 | isa = XCBuildConfiguration; 362 | buildSettings = { 363 | FRAMEWORK_SEARCH_PATHS = ( 364 | "$(inherited)", 365 | "$(DEVELOPER_FRAMEWORKS_DIR)", 366 | ); 367 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 368 | INFOPLIST_FILE = "UnitTests/UnitTests-Info.plist"; 369 | PRODUCT_BUNDLE_IDENTIFIER = "com.charcoaldesign.${PRODUCT_NAME:rfc1034identifier}"; 370 | PRODUCT_NAME = UnitTests; 371 | TEST_HOST = "$(BUNDLE_LOADER)"; 372 | WRAPPER_EXTENSION = xctest; 373 | }; 374 | name = Release; 375 | }; 376 | /* End XCBuildConfiguration section */ 377 | 378 | /* Begin XCConfigurationList section */ 379 | 01D28C671907BFC80021C719 /* Build configuration list for PBXProject "UnitTests" */ = { 380 | isa = XCConfigurationList; 381 | buildConfigurations = ( 382 | 01D28C961907BFC80021C719 /* Debug */, 383 | 01D28C971907BFC80021C719 /* Release */, 384 | ); 385 | defaultConfigurationIsVisible = 0; 386 | defaultConfigurationName = Release; 387 | }; 388 | 01D28C9B1907BFC80021C719 /* Build configuration list for PBXNativeTarget "UnitTests" */ = { 389 | isa = XCConfigurationList; 390 | buildConfigurations = ( 391 | 01D28C9C1907BFC80021C719 /* Debug */, 392 | 01D28C9D1907BFC80021C719 /* Release */, 393 | ); 394 | defaultConfigurationIsVisible = 0; 395 | defaultConfigurationName = Release; 396 | }; 397 | /* End XCConfigurationList section */ 398 | }; 399 | rootObject = 01D28C641907BFC80021C719 /* Project object */; 400 | } 401 | -------------------------------------------------------------------------------- /Tests/UnitTests.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Tests/UnitTests.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Tests/UnitTests.xcodeproj/xcshareddata/xcschemes/UnitTests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 16 | 18 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 41 | 42 | 43 | 44 | 50 | 51 | 53 | 54 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Tests/UnitTests/BaseModelTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseModelTests.m 3 | // 4 | // Created by Nick Lockwood on 12/01/2012. 5 | // Copyright (c) 2012 Charcoal Design. All rights reserved. 6 | // 7 | 8 | 9 | #import 10 | #import "BaseModel.h" 11 | 12 | 13 | @interface TestModel : BaseModel 14 | 15 | @property (nonatomic, strong) NSString *string; 16 | @property (nonatomic, strong) NSDate *date; 17 | 18 | @end 19 | 20 | 21 | @implementation TestModel 22 | 23 | @synthesize string, date; 24 | 25 | + (BMFileFormat)saveFormat 26 | { 27 | return BMFileFormatJSON; 28 | } 29 | 30 | @end 31 | 32 | 33 | @interface BaseModelTests : XCTestCase 34 | 35 | @end 36 | 37 | 38 | @implementation BaseModelTests 39 | 40 | - (void)testSetSharedInstanceToNil 41 | { 42 | 43 | //set property on shared instance 44 | [TestModel sharedInstance].string = @"foo"; 45 | 46 | //replace shared instance 47 | [TestModel setSharedInstance:nil]; 48 | 49 | //verify that it worked 50 | XCTAssertFalse([TestModel hasSharedInstance]); 51 | XCTAssertNil([TestModel sharedInstance].string); 52 | } 53 | 54 | - (void)testSaveDateAsJSON 55 | { 56 | [TestModel sharedInstance].date = [NSDate date]; 57 | XCTAssertNoThrow([[TestModel sharedInstance] save]); 58 | } 59 | 60 | @end 61 | 62 | -------------------------------------------------------------------------------- /Tests/UnitTests/UnitTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | --------------------------------------------------------------------------------