Guest User

Untitled

a guest
Apr 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. //
  2. // ImageLoadingOp.m
  3. // PersonList
  4. //
  5. // Created by Marcio Valenzuela on 10/20/09.
  6. // Copyright 2009 Personal. All rights reserved.
  7. //
  8.  
  9. #import "ImageLoadingOp.h"
  10.  
  11. NSString *const ImageResultKey = @"image";
  12. NSString *const URLResultKey = @"url";
  13.  
  14. @implementation ImageLoadingOp
  15.  
  16. - (id)initWithImageURL:(NSURL *)theImageURL target:(id)theTarget action:(SEL)theAction
  17. {
  18. self = [super init];
  19. if (self) {
  20. imageURL = [theImageURL copy];
  21. target = [theTarget retain];
  22. action = theAction;
  23. }
  24. NSLog(@"EXITING INITIMAGELOADINGOP");
  25. return self;
  26. }
  27.  
  28. - (void)dealloc
  29. {
  30. [super dealloc];
  31. [imageURL release];
  32. [target release];
  33. }
  34.  
  35. - (void)main
  36. {
  37. // Synchronously oad the data from the specified URL.
  38. NSLog(@"ENTER IMAGELOADINGOP MAIN");
  39. NSData *data = [[NSData alloc] initWithContentsOfURL:imageURL];
  40. UIImage *image = [[UIImage alloc] initWithData:data];
  41. NSLog(@"IN ILOP main data %@", data);
  42.  
  43. // Package it up to send back to our target.
  44. NSDictionary *result = [NSDictionary dictionaryWithObjectsAndKeys:image, ImageResultKey, imageURL, URLResultKey, nil];
  45. [target performSelectorOnMainThread:action withObject:result waitUntilDone:NO];
  46.  
  47. [data release];
  48. [image release];
  49. NSLog(@"EXITING IMAGELOADINGOP MAIN dict");
  50. }
  51.  
  52. @end
Add Comment
Please, Sign In to add comment