我不知道下面的代码有什么问题。我认为它应该有效。我得到的错误是EXC_BAD_ACCESS
// Playground - noun: a place where people can play
import UIKit
extension NSCalendar {
func nextDay(date:NSDate) -> NSDate {
var dateComponents = self.components(.YearCalendarUnit | .MonthCalendarUnit | .DayCalendarUnit, fromDate: date)
dateComponents.day += 1
let nextDate = self.dateFromComponents(dateComponents)!
return nextDate
}
func getNextDay(date:NSDate) -> NSDate {
var method = nextDay
let tomorrow = method(date)
return tomorrow
}
}
![enter image description here][2]let calendar = NSCalendar.currentCalendar()
let today = NSDate()
let tomorrow = calendar.getNextDay(today)