Skip to content

Instantly share code, notes, and snippets.

@gorenje
Created March 10, 2011 10:25
Show Gist options
  • Save gorenje/863889 to your computer and use it in GitHub Desktop.
Save gorenje/863889 to your computer and use it in GitHub Desktop.
@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