如何在 IOS 的 Pinterest SDK 中访问 PDKPin 的 Image/largest 图像属性

How to access a PDKPin's Image/largest Image properties in Pinterest SDK for IOS

我知道这是一个较新的 API,所以我从 SDK 添加了相关的源代码。我遇到的问题是它是用 Obj-C 编写的,我不知道它是什么,所以很难弄清楚 SDK/Example 应用程序在做什么。根据文档 https://github.com/pinterest/ios-pdk,有 .image.largestImage 属性 可用。在 Xcode、PDKPin.imagePDKPin.largestImage 中将编译,但它们 return 为零。

在示例应用程序中,他们在 PDKPin 上成功调用了 .image,所以我无法弄清楚他们在做什么而我没有:

#pragma mark - UICollectionViewDataSource

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return [self.pins count];
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    PDKPin *pin = self.pins[indexPath.row];
    PDKPinCell *cell = (PDKPinCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"PinCell" forIndexPath:indexPath];
    cell.descriptionLabel.text = pin.descriptionText;


    [cell.imageView setImageWithURL:pin.largestImage.url];

    return cell;
}

看起来 .image 属性 可能在 PDKImageInfo 上:

#import "PDKImageInfo.h"

@interface PDKImageInfo()

@property (nonatomic, assign, readwrite) CGFloat width;
@property (nonatomic, assign, readwrite) CGFloat height;
@property (nonatomic, copy, readwrite) NSURL *url;
@end

    @implementation PDKImageInfo

    + (instancetype)imageFromDictionary:(NSDictionary *)dictionary
    {
        PDKImageInfo *image = [[PDKImageInfo alloc] init];
        image.width = [dictionary[@"width"] floatValue];
        image.height = [dictionary[@"height"] floatValue];
        if ([dictionary[@"url"] isKindOfClass:[NSString class]]) {
            image.url = [NSURL URLWithString:dictionary[@"url"]];
        }
        return image;
    }

    @end

但我不知道如何像他们在示例应用程序中那样从 PDKPin 访问它。谁能看到我错过了什么?

问题是我只是忘记了 getAuthenticatedUserPinsWithFields 需要一个字典,而且我没有添加 image

PDKClient.sharedInstance().getAuthenticatedUserPinsWithFields(Set(["url", "note", "link", "image"])