次のコードを使用して、TableViewで検索されたすべてのビデオを取得できます
.hファイル内
#import <UIKit/UIKit.h>
#import "GData.h"
#import "GDataFeedYouTubeVideo.h"
@interface RootViewController : UIViewController {
GDataFeedYouTubeVideo* feed;
NSMutableDictionary *imageDownloadsInProgress;
}
@property(retain,nonatomic) NSMutableDictionary *imageDownloadsInProgress;
@property(retain,nonatomic)GDataFeedYouTubeVideo* feed;
-(void)requestFinishForYouTube:(GDataServiceTicket *)ticket FinishedWithFeed:(GDataFeedBase *)aFeed error:(NSError *)error;
- (void)setFlickrPhotoONU:(NSString*)flickrPhoto:(UIImageView *)imgV;
-(void)downloadImagesInBackGroundONU:(NSDictionary*)data;
@終わり
.mファイル内
@interface RootViewController (PrivateMethods)
-(GDataServiceGoogleYouTube *)youTubeService;
@end
@implementation RootViewController
@synthesize feed,imageDownloadsInProgress;
-(GDataServiceGoogleYouTube *)youTubeService
{
static GDataServiceGoogleYouTube *_service = nil;
if (!_service)
{
_service = [[GDataServiceGoogleYouTube alloc]init];
[_service setUserAgent:@"AppWhirl-Userapp-1.0"];
[_service setShouldCacheDatedData:YES];
[_service setServiceShouldFollowNextLinks:YES];
}
[_service setUserCredentialsWithUsername:nil password:nil];
return _service;
}
- (void)viewDidLoad
{
GDataServiceGoogleYouTube *service = [self youTubeService];
NSString *searchString = @"Leo Messi Goal!"; // You can write here whatever you want to looking for !!
NSURL *feedURL = [GDataServiceGoogleYouTube youTubeURLForFeedID:nil];
GDataQueryYouTube* query = [GDataQueryYouTube youTubeQueryWithFeedURL:feedURL];
[query setVideoQuery:searchString];
[query setMaxResults:50];
[service fetchFeedWithQuery:query delegate:self didFinishSelector:@selector(requestFinishForYouTube:FinishedWithFeed:error:)];
[super viewDidLoad];
}
-(void)requestFinishForYouTube:(GDataServiceTicket *)ticket FinishedWithFeed:(GDataFeedBase *)aFeed error:(NSError *)error
{
finish = 1;
NSLog(@"%@",aFeed);
self.feed = (GDataFeedYouTubeVideo *)aFeed;
}
私はそれを使用しています、そしてそれは私とうまく働いています!
それがあなたを助けることを願っています!