2011-11-18 65 views
0

我正在製作一個應用程序,需要上傳多個視頻到youtube。 GData的問題是我不知道如何將信息傳遞給它的回調函數,以便我可以區分不同的上傳。iOS GData多個youtube上傳

(void)uploadTicket:(GDataServiceTicket *)ticket 
    finishedWithEntry:(GDataEntryYouTubeVideo *)videoEntry 
       error:(NSError *)error 

在ASIHttpRequest中有「userInfo」屬性允許用戶將信息傳遞給requestFinish回調。 GData youtube上傳請求怎麼樣?

- (void)uploadToYoutube: (NSString *)login andPassword:(NSString *)password withVideo:(NSData *)videoData forSighting:(SightingDB *)sighting { 


    [service setYouTubeDeveloperKey:DEVELOPER_KEY]; 

    NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:kGDataServiceDefaultUser]; 


    NSString *titleStr = @"title"; 

    // gather all the metadata needed for the mediaGroup 

    GDataMediaTitle *title = [GDataMediaTitle textConstructWithString:titleStr]; 
    [titleStr release]; 

    NSString *categoryStr = @"Entertainment"; 
    GDataMediaCategory *category = [GDataMediaCategory mediaCategoryWithString:categoryStr]; 
    [category setScheme:kGDataSchemeYouTubeCategory]; 

    NSString *descStr = @"descripion" 

    GDataMediaDescription *desc = [GDataMediaDescription textConstructWithString:descStr]; 
    [descStr release]; 

    NSArray *kwords = [[NSArray alloc] initWithObjects:@"xxx",@"weee",nil]; 
    GDataMediaKeywords *keywords = [GDataMediaKeywords keywordsWithStrings:kwords]; 



    BOOL isPrivate = NO; 

    GDataYouTubeMediaGroup *mediaGroup = [GDataYouTubeMediaGroup mediaGroup]; 
    [mediaGroup setMediaTitle:title]; 
    [mediaGroup setMediaDescription:desc]; 
    [mediaGroup addMediaCategory:category]; 
    [mediaGroup setMediaKeywords:keywords]; 
    [mediaGroup setIsPrivate:isPrivate]; 

    NSString *mimeType = [GDataUtilities MIMETypeForFileAtPath:@"" 
               defaultMIMEType:@"video/mp4"]; 

    // create the upload entry with the mediaGroup and the file data 
    GDataEntryYouTubeUpload *entry; 

    entry = [GDataEntryYouTubeUpload uploadEntryWithMediaGroup:mediaGroup 
                  data:videoData 
                 MIMEType:mimeType 
                  slug:@"movie.mov"]; 



    SEL progressSel = @selector(ticket:hasDeliveredByteCount:ofTotalByteCount:); 
    [service setServiceUploadProgressSelector:progressSel]; 

    GDataServiceTicket *ticket; 
    ticket = [service fetchEntryByInsertingEntry:entry 
             forFeedURL:url 
             delegate:self 
           didFinishSelector:@selector(uploadTicket:finishedWithEntry:error:)]; 

回答

0

該票證支持setProperty:forKey:以及setUserData :.

或者只是使用塊回調而不是委託和選擇器。