根据字符串属性按字母顺序对对象数组进行排序 [英] Sorting Array of Objects alphabetically based on a string attribute

查看:94
本文介绍了根据字符串属性按字母顺序对对象数组进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITableView,其中填充了产品"类型的对象数组,每个对象都具有字符串类型的名称"属性.单击一个单元格时,将显示一个模式视图,其中包含有关该产品的更多信息.

I have a UITableView which is populated with an array of objects of type 'Product' which each have a 'name' attribute of type string. When a cell is clicked, a modal view is shown with more information on that product.

我想做的就是根据产品名称属性的首字母将产品分成几部分. (如iPhone联系人).

What I would like to do is split the products up into sections depending on the first letter of their name attribute. (Like iPhone contacts).

我已经为此苦苦挣扎了一段时间,而且我似乎在网上找不到任何能解决我的特殊问题的东西.

I have been struggling with this for a while now, and I can't seem to find anything online that solves my particular problem..

有人能指出我正确的方向吗?

Could someone point me in the right direction?

推荐答案

在SO上有几个很好的例子.这是一个很好的例子:

There are several good examples here on SO. Here is a good example:

如何对带有自定义对象的NSMutableArray进行排序它吗?

这篇关于根据字符串属性按字母顺序对对象数组进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆