From b82e44ea2d31e5cadf1aefdea833f85e4575d91b Mon Sep 17 00:00:00 2001 From: eibakke Date: Sun, 16 Feb 2014 21:34:02 -0600 Subject: [PATCH] The first Commit This is the first commit of the persist me test run --- AppDelegate.h | 22 + AppDelegate.m | 154 +++ Default-568h@2x.png | Bin 0 -> 18594 bytes Default.png | Bin 0 -> 6540 bytes Default@2x.png | Bin 0 -> 16107 bytes PersistMe-Info.plist | 38 + PersistMe-Prefix.pch | 15 + .../PersistMe.xcdatamodel/contents | 10 + PersistMe.xcdatamodeld/_xccurrentversion | 8 + Person.h | 17 + Person.m | 13 + ViewController.h | 22 + ViewController.m | 115 ++ ViewController.xib | 1024 +++++++++++++++++ en.lproj/InfoPlist.strings | 2 + main.m | 18 + 16 files changed, 1458 insertions(+) create mode 100755 AppDelegate.h create mode 100755 AppDelegate.m create mode 100755 Default-568h@2x.png create mode 100755 Default.png create mode 100755 Default@2x.png create mode 100755 PersistMe-Info.plist create mode 100755 PersistMe-Prefix.pch create mode 100755 PersistMe.xcdatamodeld/PersistMe.xcdatamodel/contents create mode 100755 PersistMe.xcdatamodeld/_xccurrentversion create mode 100755 Person.h create mode 100755 Person.m create mode 100755 ViewController.h create mode 100755 ViewController.m create mode 100755 ViewController.xib create mode 100755 en.lproj/InfoPlist.strings create mode 100755 main.m diff --git a/AppDelegate.h b/AppDelegate.h new file mode 100755 index 0000000..e45d7ac --- /dev/null +++ b/AppDelegate.h @@ -0,0 +1,22 @@ +// +// AppDelegate.h +// PersistMe +// +// Created by Eivind Bakke on 2/16/14. +// Copyright (c) 2014 HALEALEI. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; +@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; +@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; + +- (void)saveContext; +- (NSURL *)applicationDocumentsDirectory; + +@end diff --git a/AppDelegate.m b/AppDelegate.m new file mode 100755 index 0000000..d9a4d59 --- /dev/null +++ b/AppDelegate.m @@ -0,0 +1,154 @@ +// +// AppDelegate.m +// PersistMe +// +// Created by Eivind Bakke on 2/16/14. +// Copyright (c) 2014 HALEALEI. All rights reserved. +// + +#import "AppDelegate.h" +#import "ViewController.h" + +@implementation AppDelegate + +@synthesize managedObjectContext = _managedObjectContext; +@synthesize managedObjectModel = _managedObjectModel; +@synthesize persistentStoreCoordinator = _persistentStoreCoordinator; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + // Override point for customization after application launch. + + ViewController *vc = [[ViewController alloc]init]; + [self.window setRootViewController:vc]; + + self.window.backgroundColor = [UIColor whiteColor]; + [self.window makeKeyAndVisible]; + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application +{ + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application +{ + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application +{ + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application +{ + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application +{ + // Saves changes in the application's managed object context before the application terminates. + [self saveContext]; +} + +- (void)saveContext +{ + NSError *error = nil; + NSManagedObjectContext *managedObjectContext = self.managedObjectContext; + if (managedObjectContext != nil) { + if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) { + // Replace this implementation with code to handle the error appropriately. + // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. + NSLog(@"Unresolved error %@, %@", error, [error userInfo]); + abort(); + } + } +} + +#pragma mark - Core Data stack + +// Returns the managed object context for the application. +// If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application. +- (NSManagedObjectContext *)managedObjectContext +{ + if (_managedObjectContext != nil) { + return _managedObjectContext; + } + + NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; + if (coordinator != nil) { + _managedObjectContext = [[NSManagedObjectContext alloc] init]; + [_managedObjectContext setPersistentStoreCoordinator:coordinator]; + } + return _managedObjectContext; +} + +// Returns the managed object model for the application. +// If the model doesn't already exist, it is created from the application's model. +- (NSManagedObjectModel *)managedObjectModel +{ + if (_managedObjectModel != nil) { + return _managedObjectModel; + } + NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"PersistMe" withExtension:@"momd"]; + _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; + return _managedObjectModel; +} + +// Returns the persistent store coordinator for the application. +// If the coordinator doesn't already exist, it is created and the application's store added to it. +- (NSPersistentStoreCoordinator *)persistentStoreCoordinator +{ + if (_persistentStoreCoordinator != nil) { + return _persistentStoreCoordinator; + } + + NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"PersistMe.sqlite"]; + + NSError *error = nil; + _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; + if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) { + /* + Replace this implementation with code to handle the error appropriately. + + abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. + + Typical reasons for an error here include: + * The persistent store is not accessible; + * The schema for the persistent store is incompatible with current managed object model. + Check the error message to determine what the actual problem was. + + + If the persistent store is not accessible, there is typically something wrong with the file path. Often, a file URL is pointing into the application's resources directory instead of a writeable directory. + + If you encounter schema incompatibility errors during development, you can reduce their frequency by: + * Simply deleting the existing store: + [[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil] + + * Performing automatic lightweight migration by passing the following dictionary as the options parameter: + @{NSMigratePersistentStoresAutomaticallyOption:@YES, NSInferMappingModelAutomaticallyOption:@YES} + + Lightweight migration will only work for a limited set of schema changes; consult "Core Data Model Versioning and Data Migration Programming Guide" for details. + + */ + NSLog(@"Unresolved error %@, %@", error, [error userInfo]); + abort(); + } + + return _persistentStoreCoordinator; +} + +#pragma mark - Application's Documents directory + +// Returns the URL to the application's Documents directory. +- (NSURL *)applicationDocumentsDirectory +{ + return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; +} + +@end diff --git a/Default-568h@2x.png b/Default-568h@2x.png new file mode 100755 index 0000000000000000000000000000000000000000..0891b7aabfcf3422423b109c8beed2bab838c607 GIT binary patch literal 18594 zcmeI4X;f257Jx&9fS`ixvS;&$x8J@slQFSel)6zJN=?13FB7H(lQjRkSy8x_-S~tvu2gzn1oS+dLcF#eqtq$ z%tf9TTvX?`)R@}3uBI;jzS-=ZR-Td&MHaS&;!0?Ni*#$#`n*~CcQK)Q9vAQ~TUpnI!j)a2biYK^R)M~A5wUDZhx?ULMX z3x1P&qt=trOY6P2U67L=m=U?F|5#Uj(eCueNTZaHs_ceWiHeET+j+tp3Jt9g(ekqP z2WOvfR{qV+9r+o4J5?qK>7;;^+I7tGv-i)es$X_D=EoKF+S?zsyj^oRFElP}c}JT< zd8SUs-?O?}2YD#ngKbnHgzHBcboxK_2r9l(?eNCl-pEzkJm}fY?WC*jnS?VBE4EpY zO$fEejz6fU;W2Kl>JeQBZBl-%Irg`obSlg*@4QB;Dd1H7^Oi5wvt4d{RZ!8Og?^aE z)k0$1g+V3fd(gdQ3d&q2q-FL*uy#}|bc^=VhFsl0jBgUGJ+-s3U8MK9A!YJJMxpci z5hJ%|{DwV48fZn0{n5l$N_KcSb#NKE4plB`9I6Zt=Z!~-zw0{9tg$L&Ju1F0X)Cy8 zKF;(&lJ>x)Jw(=;p~sF(Sd9VWGwFE2rnyS9!f^DZ8+aCLq zQ};>lcJ1GDLqjm6Hd>|Eabno@P`~Bn(~6^aD_#yoEH(a?Nm1S<;S+hSxI5d16^<1lEM3NPFi zkqPrpL)+ zgnseFikg`gJVBha1&7C4;O6>h=dt~`ND+;Zd?W(4v2JIb7Pt>Td42%M-Ju-XAH#Pns762L}K3 zDhvsRqN0Ni(1UrishD2YvV?4*h2iFj$+&N||Fn$4n|^NSU+o?~jq`0jVQt8T9l{7b zXiwwODFh2V!Q6sqP9S>WH$oOf$N~=d0-bqTlD61!=`&0eAP-F>XN?*|gtOXX{ zQVTWyYo4ZK0GAw!GHf|pz9`D;-bbb*5LBX*{bnz|+)$@&P9|ORM2o?95{;ejvo&r- zq8cBhTN6nn)7~W>54U)%-F_-b?YKdfk5I8MHcuzBD5)!;yv#Z&R&^y=@=>VTIMy#r zX&U<=BsPkdqcMe<_}2+>H%XKyrr5ZR8_KVe>ZqYN z^=^~TFD};;rHJ$U;{~w^hYojl4hRI@SH$^K{YEo=sg)WY87r!*7blQK&qnpDo0`Vn zkl)9u9g=mCh&ZCJS(L4yN3k0kQ zuvg$h2KEEk51T+O0JQ+r0`R>g{jvqM0Mr6d3qUOZwE!?PI7HY@CE|dr sfw?Q;rAv?G4&^^8-z_>&sWXMxvD*gPOU4CBe-*@OtE+wfmVJNyHv)PfH~;_u literal 0 HcmV?d00001 diff --git a/Default.png b/Default.png new file mode 100755 index 0000000000000000000000000000000000000000..4c8ca6f693f96d511e9113c0eb59eec552354e42 GIT binary patch literal 6540 zcmeAS@N?(olHy`uVBq!ia0y~yU~~ZD2OMlbkt;o0To@QwR5G2N13aCb6#|O#(=u~X z85k@CTSM>X-wqM6>&y>YB4)1;;ojbLbbV-W^iFB1wa3^zCog^LCAReC4K0-?R_2{6 zrP*)4+_uWUy3w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+ + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.halealei.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/PersistMe-Prefix.pch b/PersistMe-Prefix.pch new file mode 100755 index 0000000..20b031d --- /dev/null +++ b/PersistMe-Prefix.pch @@ -0,0 +1,15 @@ +// +// Prefix header for all source files of the 'PersistMe' target in the 'PersistMe' project +// + +#import + +#ifndef __IPHONE_3_0 +#warning "This project uses features only available in iOS SDK 3.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import + #import +#endif diff --git a/PersistMe.xcdatamodeld/PersistMe.xcdatamodel/contents b/PersistMe.xcdatamodeld/PersistMe.xcdatamodel/contents new file mode 100755 index 0000000..3b8602d --- /dev/null +++ b/PersistMe.xcdatamodeld/PersistMe.xcdatamodel/contents @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/PersistMe.xcdatamodeld/_xccurrentversion b/PersistMe.xcdatamodeld/_xccurrentversion new file mode 100755 index 0000000..ae44abc --- /dev/null +++ b/PersistMe.xcdatamodeld/_xccurrentversion @@ -0,0 +1,8 @@ + + + + + _XCCurrentVersionName + PersistMe.xcdatamodel + + diff --git a/Person.h b/Person.h new file mode 100755 index 0000000..4ca661e --- /dev/null +++ b/Person.h @@ -0,0 +1,17 @@ +// +// Person.h +// PersistMe +// +// Created by Eivind Bakke on 2/16/14. +// Copyright (c) 2014 HALEALEI. All rights reserved. +// + +#import + +@interface Person : NSObject + +@property (nonatomic, strong) NSString *firstname; +@property (nonatomic, strong) NSString *lastname; + + +@end diff --git a/Person.m b/Person.m new file mode 100755 index 0000000..55f0992 --- /dev/null +++ b/Person.m @@ -0,0 +1,13 @@ +// +// Person.m +// PersistMe +// +// Created by Eivind Bakke on 2/16/14. +// Copyright (c) 2014 HALEALEI. All rights reserved. +// + +#import "Person.h" + +@implementation Person + +@end diff --git a/ViewController.h b/ViewController.h new file mode 100755 index 0000000..fb85ba6 --- /dev/null +++ b/ViewController.h @@ -0,0 +1,22 @@ +// +// ViewController.h +// PersistMe +// +// Created by Eivind Bakke on 2/16/14. +// Copyright (c) 2014 HALEALEI. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + +@property (weak, nonatomic) IBOutlet UITextField *firstname; +@property (weak, nonatomic) IBOutlet UITextField *lastname; +@property (weak, nonatomic) IBOutlet UILabel *label; +- (IBAction)addPersonButton:(id)sender; + +- (IBAction)searchPersonButton:(id)sender; + +- (IBAction)deletePersonButton:(id)sender; + +@end diff --git a/ViewController.m b/ViewController.m new file mode 100755 index 0000000..2e53937 --- /dev/null +++ b/ViewController.m @@ -0,0 +1,115 @@ +// +// ViewController.m +// PersistMe +// +// Created by Eivind Bakke on 2/16/14. +// Copyright (c) 2014 HALEALEI. All rights reserved. +// + +#import "ViewController.h" +#import "AppDelegate.h" + +@interface ViewController () +{ + NSManagedObjectContext *context; +} +@end + +@implementation ViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view from its nib. + + [[self firstname]setDelegate:self]; + [[self lastname]setDelegate:self]; + + AppDelegate *appdelegate = [[UIApplication sharedApplication] delegate]; + context = [appdelegate managedObjectContext]; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +-(BOOL)textFieldShouldReturn:(UITextField *)textField +{ + return [textField resignFirstResponder]; +} +- (IBAction)addPersonButton:(id)sender { + NSEntityDescription *entitydesc = [NSEntityDescription entityForName:@"Person" inManagedObjectContext:context]; + NSManagedObject *newPerson = [[NSManagedObject alloc]initWithEntity:entitydesc insertIntoManagedObjectContext:context]; + + [newPerson setValue:self.firstname.text forKey:@"firstname"]; + [newPerson setValue:self.lastname.text forKey:@"lastname"]; + + NSError *error; + [context save:&error]; + self.label.text = @"Person Added."; +} + +- (IBAction)searchPersonButton:(id)sender { + + NSEntityDescription *entitydesc = [NSEntityDescription entityForName:@"Person" inManagedObjectContext:context]; + NSFetchRequest *request = [[NSFetchRequest alloc]init]; + [request setEntity:entitydesc]; + + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"firstname like %@ and lastname like %@", self.firstname.text, self.lastname.text]; + [request setPredicate:predicate]; + + NSError *error; + NSArray *matchingData = [context executeFetchRequest:request error:&error]; + + if(matchingData.count <= 0) { + self.label.text=@"No Person Found."; + } + else + { + NSString *firstName; + NSString *lastName; + + for (NSManagedObject *obj in matchingData) { + firstName = [obj valueForKey:@"firstname"]; + lastName = [obj valueForKey:@"lastname"]; + } + self.label.text = [NSString stringWithFormat:@"Firstname: %@, Lastname: %@", firstName, lastName]; + } + +} + +- (IBAction)deletePersonButton:(id)sender { + + NSEntityDescription *entityDesc = [NSEntityDescription entityForName:@"Person" inManagedObjectContext:context]; + NSFetchRequest *request = [[NSFetchRequest alloc]init]; + [request setEntity:entityDesc]; + + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"firstname like %@", self.firstname.text]; + [request setPredicate:predicate]; + + NSError *error; + NSArray *matchingData = [context executeFetchRequest:request error:&error]; + + if(matchingData.count <= 0) { + self.label.text = @"No person deleted."; + } else { + for (NSManagedObject *obj in matchingData) { + [context deleteObject:obj]; + } + self.label.text = @"All instances deleted"; + [context save:&error]; + } + +} +@end diff --git a/ViewController.xib b/ViewController.xib new file mode 100755 index 0000000..0bf3ccc --- /dev/null +++ b/ViewController.xib @@ -0,0 +1,1024 @@ + + + + 1552 + 12E55 + 3084 + 1187.39 + 626.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 2083 + + + IBNSLayoutConstraint + IBProxyObject + IBUIButton + IBUILabel + IBUITextField + IBUIView + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 274 + + + + 292 + {{20, 34}, {280, 30}} + + + + _NS:9 + NO + YES + IBCocoaTouchFramework + 0 + + 3 + firstname + + 3 + MAA + + 2 + + + YES + 17 + + IBCocoaTouchFramework + + + 1 + 14 + + + Helvetica + 14 + 16 + + + + + 292 + {{20, 94}, {280, 30}} + + + + _NS:9 + NO + YES + IBCocoaTouchFramework + 0 + + 3 + lastname + + 3 + MAA + + + YES + 17 + + IBCocoaTouchFramework + + + + + + + 292 + {{20, 138}, {102, 44}} + + + + _NS:9 + NO + IBCocoaTouchFramework + 0 + 0 + 1 + Add Person + + 3 + MQA + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + 3 + MC41AA + + + 2 + 15 + + + Helvetica-Bold + 15 + 16 + + + + + 292 + {{154, 138}, {146, 44}} + + + + _NS:9 + NO + IBCocoaTouchFramework + 0 + 0 + 1 + Search Person + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + + + + + 292 + {{106, 189}, {109, 44}} + + + + _NS:9 + NO + IBCocoaTouchFramework + 0 + 0 + 1 + Delete Person + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + + + + + 292 + {{36, 254}, {233, 177}} + + + _NS:9 + NO + YES + 7 + NO + IBCocoaTouchFramework + Label + + 1 + MCAwIDAAA + darkTextColor + + + 0 + + 1 + 17 + + + Helvetica + 17 + 16 + + NO + + + + 292 + {{20, 138}, {126, 44}} + + + + _NS:9 + NO + IBCocoaTouchFramework + 0 + 0 + 1 + Add Person + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + + + + {{0, 20}, {320, 548}} + + + + + 3 + MQA + + + + + IBUIScreenMetrics + + YES + + + + + + {320, 568} + {568, 320} + + + IBCocoaTouchFramework + Retina 4 Full Screen + 2 + + IBCocoaTouchFramework + + + + + + + view + + + + 3 + + + + firstname + + + + 63 + + + + lastname + + + + 64 + + + + label + + + + 65 + + + + searchPersonButton: + + + 7 + + 95 + + + + deletePersonButton: + + + 7 + + 94 + + + + addPersonButton: + + + 7 + + 97 + + + + + + 0 + + + + + + 1 + + + + + 3 + 0 + + 3 + 1 + + 254 + + 1000 + + 3 + 9 + 3 + + + + 5 + 0 + + 5 + 1 + + 36 + + 1000 + + 3 + 9 + 3 + + + + 3 + 0 + + 4 + 1 + + 8 + + 1000 + + 6 + 24 + 3 + + + + 9 + 0 + + 9 + 1 + + 0.0 + + 1000 + + 6 + 24 + 2 + + + + 5 + 0 + + 6 + 1 + + 8 + + 1000 + + 6 + 24 + 3 + + + + 6 + 0 + + 6 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 11 + 0 + + 11 + 1 + + 0.0 + + 1000 + + 6 + 24 + 2 + + + + 11 + 0 + + 11 + 1 + + 0.0 + + 1000 + + 6 + 24 + 2 + + + + 5 + 0 + + 5 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 3 + 0 + + 3 + 1 + + 138 + + 1000 + + 3 + 9 + 3 + + + + 5 + 0 + + 5 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 6 + 0 + + 6 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 5 + 0 + + 5 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 3 + 0 + + 3 + 1 + + 94 + + 1000 + + 3 + 9 + 3 + + + + 6 + 0 + + 6 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 5 + 0 + + 5 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 3 + 0 + + 3 + 1 + + 34 + + 1000 + + 3 + 9 + 3 + + + + + + + + + + + + + -1 + + + File's Owner + + + -2 + + + + + 4 + + + + + + 5 + + + + + 8 + + + + + + 12 + + + + + 15 + + + + + 19 + + + + + 20 + + + + + 21 + + + + + 22 + + + + + 7 + 0 + + 0 + 1 + + 102 + + 1000 + + 3 + 9 + 1 + + + + + + 34 + + + + + 35 + + + + + 36 + + + + + + 37 + + + + + 41 + + + + + 43 + + + + + 7 + 0 + + 0 + 1 + + 109 + + 1000 + + 3 + 9 + 1 + + + + + + 47 + + + + + 51 + + + + + 8 + 0 + + 0 + 1 + + 177 + + 1000 + + 3 + 9 + 1 + + + + 7 + 0 + + 0 + 1 + + 233 + + 1000 + + 3 + 9 + 1 + + + + + + 61 + + + + + 62 + + + + + 71 + + + + + 72 + + + + + 77 + + + + + 7 + 0 + + 0 + 1 + + 126 + + 1000 + + 3 + 9 + 1 + + + + + + 83 + + + + + 85 + + + + + 88 + + + + + 89 + + + + + 90 + + + + + 91 + + + + + 92 + + + + + + + ViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + + + + + + + + + + + + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 97 + + + + + NSLayoutConstraint + NSObject + + IBProjectSource + ./Classes/NSLayoutConstraint.h + + + + ViewController + UIViewController + + id + id + id + + + + addPersonButton: + id + + + deletePersonButton: + id + + + searchPersonButton: + id + + + + UITextField + UILabel + UITextField + + + + firstname + UITextField + + + label + UILabel + + + lastname + UITextField + + + + IBProjectSource + ./Classes/ViewController.h + + + + + 0 + IBCocoaTouchFramework + YES + 3 + YES + 2083 + + diff --git a/en.lproj/InfoPlist.strings b/en.lproj/InfoPlist.strings new file mode 100755 index 0000000..477b28f --- /dev/null +++ b/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/main.m b/main.m new file mode 100755 index 0000000..8d201ce --- /dev/null +++ b/main.m @@ -0,0 +1,18 @@ +// +// main.m +// PersistMe +// +// Created by Eivind Bakke on 2/16/14. +// Copyright (c) 2014 HALEALEI. All rights reserved. +// + +#import + +#import "AppDelegate.h" + +int main(int argc, char *argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +}