Created
October 25, 2012 11:30
-
-
Save pita5/3952097 to your computer and use it in GitHub Desktop.
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
dispatch_queue_t queue = dispatch_queue_create("somequeue", DISPATCH_QUEUE_CONCURRENT); | |
dispatch_apply(1000000, queue, ^(size_t i) { | |
[self saveSomethingToDisk]; | |
}); | |
- (void)saveSomethingToDisk | |
{ | |
NSString* cachesPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject]; | |
NSString* someFile = [cachesPath stringByAppendingPathComponent:@"somefile"]; | |
NSData* data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"apple_rainbow_logo" ofType:@"jpg"]]; | |
BOOL ok = NO; | |
@try | |
{ | |
ok = [NSKeyedArchiver archiveRootObject:data toFile:someFile]; | |
} | |
@catch (NSException *exception) | |
{ | |
NSLog(@"Got an exception"); | |
} | |
@finally | |
{ | |
NSLog(@"written %@", ok?@"OK":@"FAILED"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment