I'm looking to use block with NSManagedObjectContext. I am trying to asynchronously download several images for one entity. The data structure I have is more or less like the following (this is pseudo-code and it is not exactly following NSManagedObject syntax).
@interface SAImageDoc : NSObject
@property(nonatomic, strong) NSString* imageUrl1;
@property(readwrite) BOOL imageUrl1Downloaded;
@property(nonatomic, strong) NSString* imageUrl2;
@property(readwrite) BOOL imageUrl2Downloaded;
@end
I am trying to asynchronous download the images using block (AFNetworking). After the image is downloaded, I would like to update the boolean value of downloaded to YES and save it to the CoreData.
The questions I have are:
Given Gabriele, Mario's answer and referencing What is NSManagedObjectContext's performBlock: used for?, I believe here is what I shall do:
To simply answer your question, you can pass the context to your download block and in that use the context's -performBlock: method to access the context.