I'm trying to display images from a JSON url in an UIImageView, similar to Tinder, using SDWebImage. Every tutorial I've come across only deal with downloading either single image urls (@"suchandsuch.png"), or displaying the images inside of tableviews (which I do not want to do).
Not sure what I am doing wrong.
My sample code: ViewController.m
-(void)viewDidLoad{
[super viewDidLoad];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"http://www.suchandsuch.com/api/sites" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
self.posts = (NSDictionary *) responseObject;
self.post = self.posts[@"sites"];
NSLog(@"JSON: %@", self.post);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
NSData *data = [[NSData alloc] initWithContentsOfURL:
[NSURL URLWithString:@"http://www.suchandsuch.com/api/sites"]];
NSError *error;
NSDictionary *jsonDict = [NSJSONSerialization
JSONObjectWithData:data
options:kNilOptions
error:&error];
NSString *logoString = [jsonDict objectForKey:@"logoURL"];
NSURL *logoURL = [NSURL URLWithString:logoString];
[self.myImage setImageWithURL:logoURL];
}