tig*_*ero 1 sorting nsarray storekit in-app-purchase ios
我试图在发送产品ID列表后对从Apple Server收到的SKProduct数组进行排序.
我想通过使用以下内容进行排序:
NSSortDescriptor *lowestPriceToHighest = [NSSortDescriptor sortDescriptorWithKey:@"self.price" ascending:YES];
NSArray *sortedProducts = [products sortedArrayUsingDescriptors:[NSArray arrayWithObject:lowestPriceToHighest]];
Run Code Online (Sandbox Code Playgroud)
但我收到错误消息:Unable to access variable "lowestPriceToHighest"
我的排序描述符是否被错误地定义了?
小智 7
尝试删除"自我"
NSSortDescriptor *lowestPriceToHighest = [NSSortDescriptor sortDescriptorWithKey:@"price" ascending:YES];
NSArray *sortedProducts = [products sortedArrayUsingDescriptors:[NSArray arrayWithObject:lowestPriceToHighest]];
Run Code Online (Sandbox Code Playgroud)
斯威夫特 4:
products.sort(by: { (p0, p1) -> Bool in
return p0.price.floatValue < p1.price.floatValue
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2245 次 |
| 最近记录: |