Created
October 13, 2010 01:35
-
-
Save pier-oliviert/623257 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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