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

标签 iphone ios cocoa-touch gdata-api picasa

我正在尝试在 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/

相关文章:

iphone - 在方法中运行时,从 nib 加载的 View 不会更新 UILabel 的内容

ios - 构建项目时出错 Xcode 显示 : "you don' t have permission"

ios - UITableView 在键盘处于事件状态时向上移动

ios - Swift - 如何在全屏视频中启用横向?

iphone - AppStore更新后神秘的应用程序崩溃

cocoa-touch - 如何获取两个日期之间的差异?

iphone - 如果我从 (__bridge) 使用 CGImageSourceCreateWithData,是否需要 "CFRelease"?

iOS 应用内购买验证

ios - 在 PDF 中搜索会过多增加应用程序的内存使用量

ios - Apple 开源和 Cocoa Touch 类(class)?