发送产品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/