Skip to content

Instantly share code, notes, and snippets.

View westonplatter's full-sized avatar

Weston Platter westonplatter

View GitHub Profile
- (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];
- (void)testExample
{
NSString *jsonString = @"{\"user\":{\" .... ";
NSError *error = nil;
NSDictionary *jsonDictionary = [NSJSONSerialization
JSONObjectWithData: [jsonString dataUsingEncoding:NSUTF8StringEncoding]
options: NSJSONReadingMutableContainers
error: &error
// {
// user: {
// email: "[email protected]",
// todos: [
// {
// id: 1,
// action: "write tests",
// },
// {
// id: 2,
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@interface Director : NSObject
@property (nonatomic,retain) NSManagedObjectContext *moc;
-(id)initWithMOC:(NSManagedObjectContext *)managedObjectContext;
- (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];
- (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"];
- (void)testUserCreate
{
User *user = [NSEntityDescription
insertNewObjectForEntityForName:@"User"
inManagedObjectContext:self.moc];
[user setEmail:@"[email protected]"];
NSError *error = nil;
BOOL result = [self.moc save:&error];
#import <XCTest/XCTest.h>
#import "CoreDataHelper.h"
#import "Todo.h"
#import "User.h"
@interface TodoTests: XCTestCase
@property (nonatomic,retain) NSManagedObjectContext *moc;
@end
@implementation TodoTests
#import "AppDelegate.h"
#import <Foundation/Foundation.h>
@interface CoreDataHelper : NSObject
+(NSManagedObjectContext *) getManagedObjectContext;
@end
/*
* 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.
*