在应用程序购买中排序
我正在为应用内购买开发一个店面。我将项目加载到 -(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
内的 NSMutableArray
中,但是我的所有产品都以数字开头。我想按升序对它们进行排序,但每当我使用 sortUsingSelector:@selector(compare:)
时,我都会收到无法识别的选择器错误。
对传入产品进行分类的正确方法是什么?任何帮助将不胜感激。
谢谢
I'm working on a store front for my in app purchases. I have the items being loaded into an NSMutableArray
within -(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
however all my products start with numbers. I'd like to sort these in ascending order but whenever I use sortUsingSelector:@selector(compare:)
I get an error for unrecognized selector.
What is the proper way to sort incoming products? Any help would be greatly appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为您可以为
compareTitle:
方法创建一个本地类别,并在您的数组排序中使用它。I think you could have created a local category for a
compareTitle:
method and used that in your sort of the array.最终更改了产品名称。
Ended up changing the product names.
很好的解决方案 epatel!由于海报的产品有数字(和我的一样),我改变了实现来执行 NSNumericSearch,如下所示:
Great solution epatel! Since the poster's products have numbers (as do mine), I altered the implementation to do an NSNumericSearch like so: