Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ImageLoadingOp.m
- // PersonList
- //
- // Created by Marcio Valenzuela on 10/20/09.
- // Copyright 2009 Personal. All rights reserved.
- //
- #import "ImageLoadingOp.h"
- NSString *const ImageResultKey = @"image";
- NSString *const URLResultKey = @"url";
- @implementation ImageLoadingOp
- - (id)initWithImageURL:(NSURL *)theImageURL target:(id)theTarget action:(SEL)theAction
- {
- self = [super init];
- if (self) {
- imageURL = [theImageURL copy];
- target = [theTarget retain];
- action = theAction;
- }
- NSLog(@"EXITING INITIMAGELOADINGOP");
- return self;
- }
- - (void)dealloc
- {
- [super dealloc];
- [imageURL release];
- [target release];
- }
- - (void)main
- {
- // Synchronously oad the data from the specified URL.
- NSLog(@"ENTER IMAGELOADINGOP MAIN");
- NSData *data = [[NSData alloc] initWithContentsOfURL:imageURL];
- UIImage *image = [[UIImage alloc] initWithData:data];
- NSLog(@"IN ILOP main data %@", data);
- // Package it up to send back to our target.
- NSDictionary *result = [NSDictionary dictionaryWithObjectsAndKeys:image, ImageResultKey, imageURL, URLResultKey, nil];
- [target performSelectorOnMainThread:action withObject:result waitUntilDone:NO];
- [data release];
- [image release];
- NSLog(@"EXITING IMAGELOADINGOP MAIN dict");
- }
- @end
Add Comment
Please, Sign In to add comment