diff --git a/Mac Example/Classes/Controllers/NearbySpotsController.m b/Mac Example/Classes/Controllers/NearbySpotsController.m index a62b5db..9908531 100644 --- a/Mac Example/Classes/Controllers/NearbySpotsController.m +++ b/Mac Example/Classes/Controllers/NearbySpotsController.m @@ -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; } diff --git a/Mac Example/Classes/Models/Spot.h b/Mac Example/Classes/Models/Spot.h index e3c9954..0530815 100644 --- a/Mac Example/Classes/Models/Spot.h +++ b/Mac Example/Classes/Models/Spot.h @@ -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; diff --git a/Mac Example/Classes/Models/Spot.m b/Mac Example/Classes/Models/Spot.m index 9f554f5..43e2ab7 100644 --- a/Mac Example/Classes/Models/Spot.m +++ b/Mac Example/Classes/Models/Spot.m @@ -27,6 +27,7 @@ @implementation Spot @synthesize name = _name; @synthesize imageURLString = _imageURLString; +@synthesize image = _image; @synthesize latitude = _latitude; @synthesize longitude = _longitude; @dynamic location;