This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (BOOL)loadJSON:(NSDictionary *)jsonDictionary | |
| { | |
| BOOL result = nil; | |
| NSDictionary *userDictionary = [jsonDictionary valueForKey:@"user"]; | |
| NSString *userEmail = [userDictionary valueForKey:@"email"]; | |
| User *user = [NSEntityDescription insertNewObjectForEntityForName:@"User" inManagedObjectContext:self.moc]; | |
| [user setEmail:userEmail]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)testExample | |
| { | |
| NSString *jsonString = @"{\"user\":{\" .... "; | |
| NSError *error = nil; | |
| NSDictionary *jsonDictionary = [NSJSONSerialization | |
| JSONObjectWithData: [jsonString dataUsingEncoding:NSUTF8StringEncoding] | |
| options: NSJSONReadingMutableContainers | |
| error: &error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // { | |
| // user: { | |
| // email: "[email protected]", | |
| // todos: [ | |
| // { | |
| // id: 1, | |
| // action: "write tests", | |
| // }, | |
| // { | |
| // id: 2, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <Foundation/Foundation.h> | |
| #import <CoreData/CoreData.h> | |
| @interface Director : NSObject | |
| @property (nonatomic,retain) NSManagedObjectContext *moc; | |
| -(id)initWithMOC:(NSManagedObjectContext *)managedObjectContext; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void) testRelationshipTodoUser | |
| { | |
| // Create user and todo | |
| User *user = [NSEntityDescription insertNewObjectForEntityForName:@"User" inManagedObjectContext:self.moc]; | |
| [user setEmail:@"[email protected]"]; | |
| Todo *todo = [NSEntityDescription insertNewObjectForEntityForName:@"Todo" inManagedObjectContext:self.moc]; | |
| [todo setAction:@"first"]; | |
| [todo setUser:user]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)testRelationshipUserTodos | |
| { | |
| // Create User and Todos | |
| User *user = [NSEntityDescription insertNewObjectForEntityForName:@"User" inManagedObjectContext:self.moc]; | |
| [user setEmail:@"[email protected]"]; | |
| Todo *todo_1 = [NSEntityDescription insertNewObjectForEntityForName:@"Todo" inManagedObjectContext:self.moc]; | |
| [todo_1 setAction:@"first"]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)testUserCreate | |
| { | |
| User *user = [NSEntityDescription | |
| insertNewObjectForEntityForName:@"User" | |
| inManagedObjectContext:self.moc]; | |
| [user setEmail:@"[email protected]"]; | |
| NSError *error = nil; | |
| BOOL result = [self.moc save:&error]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <XCTest/XCTest.h> | |
| #import "CoreDataHelper.h" | |
| #import "Todo.h" | |
| #import "User.h" | |
| @interface TodoTests: XCTestCase | |
| @property (nonatomic,retain) NSManagedObjectContext *moc; | |
| @end | |
| @implementation TodoTests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import "AppDelegate.h" | |
| #import <Foundation/Foundation.h> | |
| @interface CoreDataHelper : NSObject | |
| +(NSManagedObjectContext *) getManagedObjectContext; | |
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * This is a manifest file that'll be compiled into application.css, which will include all the files | |
| * listed below. | |
| * | |
| * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, | |
| * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. | |
| * | |
| * You're free to add application-wide styles to this file and they'll appear at the top of the | |
| * compiled file, but it's generally better to create a new file per style scope. | |
| * |