Fixing Mac example to work without AFImageCache coupling

This commit is contained in:
Mattt Thompson 2011-11-21 10:23:50 -06:00
parent 5b5b32c5b8
commit fd2f678ac1
3 changed files with 8 additions and 7 deletions

View file

@ -25,7 +25,6 @@
#import "Spot.h"
#import "AFImageRequestOperation.h"
#import "AFImageCache.h"
@interface NearbySpotsController ()
@property (strong) NSArray *nearbySpots;
@ -103,19 +102,18 @@
Spot *spot = [self.nearbySpots objectAtIndex:row];
if ([[tableColumn dataCell] isMemberOfClass:[NSImageCell class]]) {
NSURL *imageURL = [NSURL URLWithString:spot.imageURLString];
NSImage *image = [[AFImageCache sharedImageCache] cachedImageForURL:imageURL cacheName:nil];
if (!image) {
if (spot.image) {
return spot.image;
} else {
NSURLRequest *imageRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:spot.imageURLString]];
AFImageRequestOperation *operation = [AFImageRequestOperation imageRequestOperationWithRequest:imageRequest success:^(NSImage *image) {
spot.image = image;
[tableView reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:row] columnIndexes:[NSIndexSet indexSetWithIndex:0]];
}];
[self.imageOperationQueue addOperation:operation];
image = [NSImage imageNamed:@"placeholder-stamp.png"];
return [NSImage imageNamed:@"placeholder-stamp.png"];
}
return image;
} else {
return spot.name;
}

View file

@ -27,12 +27,14 @@
@private
NSString *_name;
NSString *_imageURLString;
NSImage *_image;
NSNumber *_latitude;
NSNumber *_longitude;
}
@property (strong) NSString *name;
@property (strong) NSString *imageURLString;
@property (strong) NSImage *image;
@property (strong) NSNumber *latitude;
@property (strong) NSNumber *longitude;
@property (readonly) CLLocation *location;

View file

@ -27,6 +27,7 @@
@implementation Spot
@synthesize name = _name;
@synthesize imageURLString = _imageURLString;
@synthesize image = _image;
@synthesize latitude = _latitude;
@synthesize longitude = _longitude;
@dynamic location;