2016-02-18 33 views
0

我有一个swift NSDates的数组。日期只有几小时和几分钟。我曾尝试排序NSDates的数组swift

times.sortInPlace({ $0.date.compare($1.date) == NSComparisonResult.OrderedAscending }) 

,但我得到一个错误“静态成员‘日期’不能在类型‘的NSDate’的情况下使用,我得到了1970年的尝试,以及同样的错误。

+5

你可以看一下这个http://stackoverflow.com/questions/26577496/how-do-i-sort-a-swift-array-containing-实例-的-nsmanagedobject子类,由 – Breek

回答

3

你是试图访问的NSDate日期属性尝试这样的:

times.sortInPlace({ $0.compare($1) == NSComparisonResult.OrderedAscending })