I’m trying to get video thumbnails from Vimeo, but for some reason, I cannot turn the returned NSData into a UIImage. Here’s my code. How do I turn NSData of type text/html; charset=UTF-8 into a UIImage?
-(void)getThumbnails
{
int count = _videos.count;
Video* v = nil;
RKRequest* r = nil;
for( int i = 0; i<count; i++)
{
v = [_videos objectAtIndex:i];
r = [[RKClient sharedClient] get:v.thumbnail delegate:self];
GMGridViewCell* gridViewCell = [self GMGridView:_gmGridView cellForItemAtIndex:i];
//prints http://b.vimeocdn.com/ts/257/009/257009714_200.jpg
NSLog(@"thumbnail url: %@",v.thumbnail);
[r setUserData:gridViewCell];
}
}
Here’s the response:
-(void)requestQueue:(RKRequestQueue *)queue didLoadResponse:(RKResponse *)response
{
if([response.request.userData isKindOfClass:[GMGridViewCell class]])
{
//prints content type: text/html; charset=UTF-8
NSLog(@"content type: %@",response.contentType);
GMGridViewCell* cell = response.request.userData;
NSData* responseBody = response.body;
UIImage* image = [UIImage imageWithData:responseBody];
cell.imageView.image = image;
}
}
Update:
after checking the response as body, it appears that vimeo returns a not found page , while typing that into an browser returns an image :/
I figured out the answer:
was prepending the default path that is set up when the client is initialized in front of the request, creating a http:// …http://… like path that the server did not recognize, replying with a not found message.