Block callback support added to the top-of-trunk library

0 views
Skip to first unread message

Greg Robbins

unread,
Nov 4, 2009, 7:32:05 PM11/4/09
to gdata-objec...@googlegroups.com
The top-of-trunk library now includes support for block-style callbacks (completion handlers) as an alternative to separate callback methods.

Blocks are currently supported by Apple just on Mac OS X 10.6; iPhone and Mac OS X 10.4 & 10.5 applications must continue to use method-style callbacks.


Fetching a feed or entry with a block callback looks like this:

[service fetchFeedWithURL:feedURL
        completionHandler:^(GDataServiceTicket *ticket, GDataFeedBase *feed, NSError *error) {
            
    if (error == nil) {
        GDataFeedPhoto *photoFeed = (GDataFeedPhoto *)feed;
        // use photoFeed
    } else {
        // handle error
    }
}];

Just as with method-style callbacks, the completion handler block is executed later, on the same thread and run loop as the fetch, once the fetch has completed.

Block callbacks are also supported by GDataHTTPFetcher.

Jeff Nichols

unread,
Nov 20, 2009, 4:23:23 AM11/20/09
to gdata-objec...@googlegroups.com
Man I wish I could use that already. Never understood how nice
closures are for async APIs till I started using Javascript heavily.

Anyways, cheers for the update that I should be able to use in 2 or 3
years! ;-)
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups
> "Google Data APIs Objective-C Client Library Discussion" group.
> To post to this group, send email to
> gdata-objec...@googlegroups.com
> To unsubscribe from this group, send email to
> gdata-objectivec-...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/gdata-objectivec-client?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
Reply all
Reply to author
Forward
0 new messages