ios - Executing code after all requests have finished (Facebook SDK) -
Is it possible to withdraw from ASCII full block in addition to the delegation? ? It is best to pass the value by calling a block to
- (NSMutableArray *) facebookGalleryImages {// array which organizes dicts for each image containing both thumbnails and the original image URL NSMutableArray Will create * allFBImages = [[NSMUTABELARROL] INIT]; // start the Facebook API call [FBRequestConnection startWithGraphPath: @ "Me / Album" completionHandler: ^ (FBRequestConnection * connection, ID result, NSError * error) {if (error!) {// Receive all the data in the album NSArray * feed = [ Result objectForKey: @ "data"]; For (Enciphese * Featured) {// Get the Album ID of each album NSString * albumID = [dict objectForKey: @ "id"]; // New API call to get image data for a specific album id [FBRequestConnection startWithGraphPath: [NSString stringWithFormat: @ "% @ / photos", ALBUMID] completionHandler: ^ (FBRequestConnection * connection, ID result, NSError * error) {If (! Error) {// Get the data of all images in album NSArray * imageFeed = [result objectForKey: @ "data"]; // For each image data object, to remove the source image url and thumbnail URL, by adding them to a dictionary (in NSDETEFIFED) {NSString * sourceURL = [DC ObjectFork: @ "source"]; NSString * thumbnailURL = [dict objectForKey: @ "picture"]; NSDictionary * imageDict = @ {@ "source": sourceURL, @ "thumbnail": thumbnailURL}; // Add a URL containing the URL for the array, which will be passed to our gallery [all FBMages adobect: ImageDict]; }}}]; }}}]; }
Your return code does not work because the methods are async best you can If you have to expand your method to complete, then your method will look like this:
- (zero) facebookGalleryImages: (Zero (^) (NSMutableArray * imagesArray, NSError * error)) Closing {NSMutableArray * allFBImages = [[NSMutableArray alloc] init]; // start the Facebook API call [FBRequestConnection startWithGraphPath: @ "Me / Album" completionHandler: ^ (FBRequestConnection * connection, ID result, NSError * error) {if (error!) {// Receive all the data in the album NSArray * feed = [ Result objectForKey: @ "data"]; For (Enciphese * Featured) {// Get the Album ID of each album NSString * albumID = [dict objectForKey: @ "id"]; // New API call to get image data for a specific album id [FBRequestConnection startWithGraphPath: [NSString stringWithFormat: @ "% @ / photos", ALBUMID] completionHandler: ^ (FBRequestConnection * connection, ID result, NSError * error) {If (! Error) {// Get the data of all images in album NSArray * imageFeed = [result objectForKey: @ "data"]; // For each image data object, to remove the source image url and thumbnail URL, by adding them to a dictionary (in NSDETEFIFED) {NSString * sourceURL = [DC ObjectFork: @ "source"]; NSString * thumbnailURL = [dict objectForKey: @ "picture"]; NSDictionary * imageDict = @ {@ "source": sourceURL, @ "thumbnail": thumbnailURL}; // Add a URL containing the URL for the array, which will be passed to our gallery [all FBMages adobect: ImageDict]; }}}]; } Completion (all FBMs, zero); } And {complete (zero, error); }}]; }
In the end, you will use as your method:
[self facebookGalleryImages: ^ (NSMutableArray * imagesArray, NSError * error) {if ( [ImagesArray calculation]> 0) {// do something with the array} other {// do something with error}};
Comments
Post a Comment