This file contains 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
func zip<X, Y, Z>(first: X[], second: Y[], transform: (X, Y) -> (Z)) -> Array<Z> { | |
var zipped = Z[]() | |
for i in 0..min(first.count, second.count) { | |
zipped.append(transform(first[i], second[i])) | |
} | |
return zipped | |
} |
This file contains 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)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
... | |
// Get the path for our model (in this case it's named 'cache') | |
NSURL *url = [[NSBundle mainBundle] URLForResource:@"cache" withExtension:@"momd"]; | |
NSPersistentStoreCoordinator *psc = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[[NSManagedObjectModel alloc] initWithContentsOfURL:url]]; /* get a coordinator */ | |
NSString *sourceStoreType = nil;/* type for the source store, or nil if not known */ ; | |
NSString *path = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) firstObject]; | |
// Figure out the full path where our store is located | |
path = [path stringByAppendingFormat:@"/%@/Cache", [[[[NSBundle mainBundle] bundleIdentifier] componentsSeparatedByString:@"."] lastObject]]; | |
NSURL *sourceStoreURL = [NSURL fileURLWithPath:path]; /* URL for the source store */ ; |