NSSortDescriptor和nil值 [英] NSSortDescriptor and nil values
本文介绍了NSSortDescriptor和nil值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用NSSortDescriptor以升序对NSDate对象进行排序。
I'm using an NSSortDescriptor to sort NSDate objects in an ascending order. However, I need nil dates to be at the bottom of the list, whereas at the moment they come at the top.
推荐答案
我们需要nil个日期到列表的底部,最后,我决定有nil值不是一个好主意,如果我想要什么是nil值出现在升序列表的底部,我应该设置日期为[NSDate distantFuture],他们检查之前显示它们。事实证明,这在应用程序中也有更多的语义意义。
In the end I have decided that having nil values is not a good idea and if I want what were nil value to appear at the bottom of the ascending list I should set the dates to [NSDate distantFuture] and them check for this before displaying them. It turns out this makes more semantic sense in within the applications as well.
这篇关于NSSortDescriptor和nil值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文