我想通过NSDate找出数组的索引。通过NSDate查找数组的索引?
生病尝试:
var sectionsInTable = [NSDate]()
let indexOfElement = sectionsInTable.indexOf(date) // where date is an NSDate in my sectionsInTable Array
print(indexOfElement)
但生病总是得到假
怎么可能从数组中得到一个NSDate的指数?
在此先感谢。
如果您已将其初始化为空,您为什么希望在'sectionsInTable'中查找日期? – WMios
这仅仅是一个例子。该数组中仍然存在一些NSDate()。 – derdida
'NSDate'对象是“精确”的。什么包含'sectionsInTables'? NSDate对象,你想在同一天同一个小时?你可以使用'indexOfObjectPassingTest:'和'isDate:equalToDate:toUnitGranularity:'。 – Larme