Я пытаюсь получить миниатюры видео от Vimeo, но по какой-то причине не могу превратить возвращенные NSData в UIImage
. Вот мой код Как мне превратить NSData
типа text/html; charset=UTF-8
в 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];
}
}
Вот ответ:
-(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;
}
}
Обновление:
после проверки ответа как тела, кажется, что vimeo возвращает не найденную страницу , а при вводе этого в браузер возвращает изображение: /