I have seen a couple similar questions about this, however none of them work correctly. (I am guessing Google updated the GData Objective-C library since those questions)
The 2 similar questions are:
Load YouTube GData feed for a single video by id
The way @grobbins explains to do it in the first link is as follows:
for (GDataEntryYouTubeVideo *videoEntry in [feed entries]) {
GDataYouTubeMediaGroup *mediaGroup = [videoEntry mediaGroup];
NSString *videoID = [mediaGroup videoID];
NSArray *mediaContents = [mediaGroup mediaContents];
GDataMediaContent *flashContent =
[GDataUtilities firstObjectFromArray:mediaContents
withValue:@"application/x-shockwave-flash"
forKeyPath:@"type"];
NSLog(@"video ID = %@, flash content URL = %@",
videoID, [flashContent URLString]);
}
The problem is that calling 'mediaGroup' throws 'unrecognized selector sent to instance...'
I have tried this with setting up videoEntry as both GDataEntryBase and GDataEntryYouTubeVideo (which is a subclass of GDataEntryBase) and no matter what the debugger shows the variable videoEntry is always of the type GDataEntryBase (even when specifying GDataEntryYouTubeVideo as above)
I could grab the XML out and parse it myself, but then whats the point of using the library? (Plus on Googles site it says you should never need to parse the XML directly)
What am I doing wrong?
How do I get the mediaGroup section of a returned Playlist?
FetchFeedWithURL: loads my method when finished, and my method has a header of:
- (void)loadedPlaylist:(GDataServiceTicket*)ticket finishedWithFeed:(GDataFeedBase*)feed error:(NSError*)error;
Found the problem!
The problem was that I forgot to add: -ObjC -all_load, to my Other Linker Flags. Once I added those, the feed entries are coming back as type GDataEntryYouTubePlaylist.
Hope this helps someone else.