Created
October 12, 2012 16:50
-
-
Save sgoodwin/3880208 to your computer and use it in GitHub Desktop.
Saving data downloaded off the inter webs
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
NSString *dataPath = [weakOperation tmpFilePath]; | |
NSManagedObjectContext *context = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType]; | |
[context setParentContext:mainContext]; | |
[context performBlock:^{ | |
NSError *findingError = nil; | |
GOFeedItem *thisItem = (GOFeedItem *)[context existingObjectWithID:objectID error:&findingError]; | |
if(!thisItem){ | |
NSLog(@"Error finding item %@: %@", [feedItem title], [findingError userInfo]); | |
} | |
[thisItem setAudioData:[NSData dataWithContentsOfFile:dataPath]]; | |
NSError *savingError = nil; | |
BOOL saved = [context save:&savingError]; | |
if(!saved){ | |
NSAssert(NO, @"FUCK!"); | |
} | |
[context reset]; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to Instruments, the child context is gone, but there's still a Malloc the size of that file there still alive.