Created
March 10, 2011 10:25
-
-
Save gorenje/863889 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 ImageLoaderWorker : CPObject | |
{ | |
CPImageView m_imageView; | |
CPImage m_image; | |
} | |
- (id)initWithUrl:(CPString)urlStr | |
imageView:(CPImageView)anImageView | |
{ | |
self = [super init]; | |
if (self) { | |
m_imageView = anImageView; | |
m_image = [[CPImage alloc] initWithContentsOfFile:urlStr]; | |
[m_image setDelegate:self]; | |
if ([m_image loadStatus] != CPImageLoadStatusCompleted) { | |
[m_imageView setImage:aImage]; | |
} | |
} | |
return self; | |
} | |
- (void)imageDidLoad:(CPImage)anImage | |
{ | |
[m_imageView setImage:anImage]; | |
} | |
@end | |
// | |
// Then something like | |
var imageView = [[CPImageView alloc] initWithFrame:....]; | |
// initialisation and setup of imageView | |
[[CPImageWorker alloc] initWithUrl:"http://www.google.com/images/logos/ps_logo2.png" imageView:imageView]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment