Skip to content

Instantly share code, notes, and snippets.

@pier-oliviert
Created October 13, 2010 01:35
Show Gist options
  • Save pier-oliviert/623257 to your computer and use it in GitHub Desktop.
Save pier-oliviert/623257 to your computer and use it in GitHub Desktop.
@implementation Profile
- (void)setImage:(UIImage *)img
{
[image release];
image = nil;
image = [img retain];
}
- (void)configureWithDictionary:(NSDictionary *)dict
{
username = [dict valueForKey:@"username"];
//Request for the image.
ASIHTTPRequest *req = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://my.doma.in/my_picture_id"]]
req.delegate = self;
req.didFinishSelector = @selector(imageSuccess:);
req.didFailSelector = @selector(imageFailed:);
[req startAsynchronous];
}
- (void)dealloc
{
[image release];
[username release];
[super dealloc];
}
- (void)imageSuccess:(ASIHTTPRequest *)req
{
self.image = [UIImage imageWithData:[req rawResponseData]];
}
- (void)imageFailed:(ASIHTTPRequest *)req
{
self.image = [UIImage imageNamed:@"imageFailed.png"];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment