gpt4 book ai didi

iphone - 获取 GDataFeedPhotoAlbum 返回错误的对象类型

转载 作者:行者123 更新时间:2023-11-29 04:47:16 24 4
gpt4 key购买 nike

我正在尝试在 iPhone 上获取 picasa 网络相册,已从 google.code 下载了代码和示例,但遇到了一个问题:获取相册提要返回的提要包含错误的对象类型 - GDataEntryBase 而不是 GDataEntryPhoto

这是我正在使用的代码:

首先,我调用它来获取我的所有专辑:

- (void)fetchAllAlbums 
{
NSLog(@"Fetching all albums");

//request albums
GDataServiceTicket *ticket;
NSURL *feedURL = [GDataServiceGooglePhotos photoFeedURLForUserID:myemail
albumID:nil
albumName:nil
photoID:nil
kind:nil
access:nil];
ticket = [_GooglePhotoService fetchFeedWithURL:feedURL
delegate:self
didFinishSelector:@selector(albumListFetchTicket:finishedWithFeed:error:)];
[self set_AlbumFetchTicket: ticket];
}

现在,在回调中我调用以获取每个返回相册的所有照片:

- (void)albumListFetchTicket:(GDataServiceTicket *)ticket
finishedWithFeed:(GDataFeedPhotoUser *)feed
error:(NSError *)error
{
[self set_UserAlbumFeed: feed];
[self set_AlbumFetchError:error];
[self set_AlbumFetchTicket:nil];

if (error == nil) {
NSLog(@"Got albums!");

for (GDataEntryPhotoAlbum * albumEntry in _UserAlbumFeed)
{
NSLog(@"Album Title: %@", [[albumEntry title] stringValue]);
{
NSLog(@"Fetching photos!");

[self set_AlbumPhotosFeed:nil];
[self set_PhotosFetchError:nil];
[self set_PhotosFetchTicket:nil];

GDataServiceTicket *ticket;
ticket = [_GooglePhotoService fetchFeedWithURL: [[albumEntry feedLink] URL]
delegate: self
didFinishSelector: @selector(photosTicket:finishedWithFeed:error:)];

[self set_PhotosFetchTicket:ticket];

}
}
}
}

这是每个相册照片提要获取的回调:

// photo list fetch callback
- (void)photosTicket:(GDataServiceTicket *)ticket
finishedWithFeed:(GDataFeedPhotoAlbum *)feed
error:(NSError *)error
{
//tell me what class you are
NSLog(@"Feed class: %@", NSStringFromClass([feed class]));

[self set_AlbumPhotosFeed: feed];
[self set_PhotosFetchError: error];
[self set_PhotosFetchTicket: ticket];

if (error == nil)
{
NSLog(@"Got Photos!");

for (GDataEntryPhoto * photo in feed)
{
NSLog(@"Title: %@", [[photo title] stringValue]);

//tell me what class you are
NSLog(@"%@", NSStringFromClass([photo class]));

//NSArray * thumbnails = [[photo mediaGroup] mediaThumbnails];
//NSLog(@"thumbnails count: %d", [thumbnails count]);
//NSLog(@"Photo thumnail url: %@", [[thumbnails objectAtIndex:0] URLString]);
}
}
}

问题在于,最后一个回调中提要中的条目不是 GDataEntryPhoto 类型,而只是基本 GDataEntryBase - 因此尝试访问它们的缩略图 URL 将使应用程序崩溃。该代码是从 google 的 cocoa(非触摸)示例复制而来的,并且它可以正常工作 - 返回的提要由 GDateEntryPhoto 对象填充。

如有任何帮助,我们将不胜感激。

最佳答案

-ObjC -all_load 添加到 xcode 项目中的其他链接器标志,然后添加 SystemConfiguration.frameworkCFNetwork.frameworkSecurity.framework构建阶段 -> 使用二进制文件链接库

关于iphone - 获取 GDataFeedPhotoAlbum 返回错误的对象类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9442583/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com