-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFlickrPhotoDownloader.m
38 lines (32 loc) · 1.06 KB
/
FlickrPhotoDownloader.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// FlickrPhotoDownloader.m
// AnimatedPhotoViewer
//
// Created by Chad Berkley on 12/1/10.
// Copyright 2010 OffHeGoes. All rights reserved.
//
#import "FlickrPhotoDownloader.h"
#import "Constants.h"
@implementation FlickrPhotoDownloader
@synthesize photo, cacheLocation;
- (id)initWithPhoto:(FlickrPhoto*)flickrPhoto writeLocation:(NSString*)cacheLoc
{
if(self = [super init])
{
NSLog(@"initialized a photo downloader");
self.photo = flickrPhoto;
self.cacheLocation = cacheLoc;
}
return self;
}
- (void)start
{
NSLog(@"writing photo data to cache for image %@", [NSString stringWithFormat:@"%i", self.photo.photoId]);
NSData *photoData = [NSData dataWithContentsOfURL:self.photo.squareIconUrl];
[photoData writeToFile:self.cacheLocation atomically:YES];
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
[userInfo setObject:[NSString stringWithFormat:@"%i", self.photo.photoId] forKey:@"photoid"];
[[NSNotificationCenter defaultCenter] postNotificationName:PHOTOWRITTEN object:self userInfo:userInfo];
//[photoData release];
}
@end