Shopify iOS SDK - 将 BuyProductVariant 转换为 BuyProduct 时出现问题

Shopify iOS SDK - issue converting BuyProductVariant to BuyProduct

我在将 BuyProductVariant 转换为 BuyProduct 时遇到问题,因为我从 BuyCart 获取了使用以下代码添加到该购物车中的所有变体的数组

NSArray *arr = cart.lineItems;

据我了解,此数组包含添加到购物车中的所有变体。

之后,我在 BuyProductVariant 中获取了这些对象

for (int j=0; j<arr.count; j++) {
     BUYProductVariant *variant = arr[j];
     //As the product is defined in BuyProductVariant class
     BUYProduct *product = variant.product;
     //But when the above line executes the app crashes, below is the description
}

exception: -[__NSDictionaryM product]: unrecognized selector sent to instance 0x7fd3286d3c50

现在,在上面的代码中,我哪里做错了,任何帮助都会对我很有帮助。

谢谢

BUYCart.lineItems 数组不包含 BUYProductVariant 对象。它包含 BUYCartLineItem 对象。您可以从中检索您的 BUYProductVariant。

for (BUYCartLineItem* line in cart.lineItems) {

    BUYProductVariant* productVariant = line.variant;
}