Gravatar loading with Objective-C

Working on iOctocat I had to integrate Gravatars. Therefore I wrote an Objective-C GravatarLoader class that I would like to share. You can use it like this:

- (void)viewDidLoad {
   [super viewDidLoad];
   gravatarLoader = [[GravatarLoader alloc] initWithTarget:self andHandle:@selector(setGravatarImage:)];
   [gravatarLoader loadEmail:@"your@email.com" withSize:50];
}

The gravatarLoader needs to be an instance variable of the class that’s using it as it loads the Gravatar asynchronously. You initialize the GravatarLoader with a target object and a selector. The selector works as request handle and gets passed an UIImage when the Gravatar is loaded. After initializing it you can load the image with the email address and the square size.

Download the GravatarLoader source.

iPhone app for GitHub

iOctocat

is GitHub in your pocket: The go to app for staying up to date with your projects on your iPhone, and iPod Touch.
It is