flickPhotosSearch
应该做什么评论自我。图像线确实。如果我取消注释,它工作正常,但由于我需要它动态工作,我需要让flickrPhotoSearch做同样的事情。它将相同的信息保存到图像数组中,但是当它离开该方法时,它不再起作用。MutableArray永久存储信息
[self flickrPhotosSearch:url];
/* self.images = [[NSMutableArray alloc] initWithObjects:
[NSArray arrayWithObjects:@"http://farm6.staticflickr.com/5095/5426345292_40ec29d5ea.jpg", @"http://farm6.staticflickr.com/5095/5426345292_40ec29d5ea_s.jpg", nil], nil]; */
NSLog(@"%@", self.images);
}
return self;
}
-(void)flickrPhotosSearch:(NSURL *) url {
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSDictionary *photos = [JSON objectForKey:@"photos"];
self.picturesOfLocations = [photos objectForKey:@"photo"];
for (NSDictionary * photo in self.picturesOfLocations){
NSString* flickrfarmID = [photo objectForKey:@"farm"];
NSString* flickrServer = [photo objectForKey:@"server"];
NSString* flickrID = [photo objectForKey:@"id"];
NSString* flickrSecret = [photo objectForKey:@"secret"];
NSString *stringURLOriginalImage = [[NSString alloc] initWithFormat:@"http://farm%@.staticflickr.com/%@/%@_%@.jpg",flickrfarmID,flickrServer, flickrID,flickrSecret];
NSString *stringURLSmallImage = [[NSString alloc] initWithFormat:@"http://farm%@.staticflickr.com/%@/%@_%@_s.jpg",flickrfarmID,flickrServer, flickrID,flickrSecret];
[self.images addObject:[NSArray arrayWithObjects:stringURLOriginalImage,stringURLSmallImage, nil]];
NSLog(@"%@", self.images);
}
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
NSLog(@"Request Failed with Error: %@, %@", error, error.userInfo);
}];
[operation start];
}
什么方法是什么?存储数组数组(内部数组有2个成员)有什么想法? – trojanfoe 2013-03-05 07:40:45
我正在使用KTPhotoBrowser,这是他们用它来加载图像的方式。一个图像用于缩略图,一个图像用于大图像。 – user1898829 2013-03-05 13:26:14