ios - 如何按价格对SKProduct数组排序

标签 ios nsarray in-app-purchase sorting storekit

发送产品ID列表后,我正在尝试对从Apple Server收到的SKProduct数组进行排序。

我只想使用以下内容进行排序:

NSSortDescriptor *lowestPriceToHighest = [NSSortDescriptor sortDescriptorWithKey:@"self.price" ascending:YES];
NSArray *sortedProducts = [products sortedArrayUsingDescriptors:[NSArray arrayWithObject:lowestPriceToHighest]];

但我收到错误消息:Unable to access variable "lowestPriceToHighest"我的排序描述符定义不正确吗?

最佳答案

尝试删除“自我”

NSSortDescriptor *lowestPriceToHighest = [NSSortDescriptor sortDescriptorWithKey:@"price" ascending:YES];
    NSArray *sortedProducts = [products sortedArrayUsingDescriptors:[NSArray arrayWithObject:lowestPriceToHighest]];

关于ios - 如何按价格对SKProduct数组排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15665325/

相关文章:

iphone - 为越狱的 iPhone 创建调整/应用程序/脚本

ios - Xcode 在多个 View Controller 中加载 NSUserDefaults

objective-c - 解析 XML 存储到 NSArray

ios - 应用内购买在模拟器上更改测试用户

iOS 应用内购买项目未显示在发行版上,使用开发者证书运行良好

ios - 从中心变换 UIView

iphone - UITapGestureRecognizer 没有做任何事情

ios - 遍历数组,索引错误

iphone - 如何从 nsarray 中消除空值?

iphone - 在重新验证 iOS 自动续订订阅时,我应该使用旧的收据数据吗?