My code takes an NSDate and reads year, month, and day, then strings them together as a single integer. I next want to convert this Int to a String, so that it can be inserted into a URL String, but without success:
let calendarUnits: NSCalendarUnit = .CalendarUnitDay | .CalendarUnitMonth | .CalendarUnitYear
let components = NSCalendar.currentCalendar().components(calendarUnits, fromDate: dateToBeExamined)
var dateInt = components.year
dateInt += components.day
dateInt += components.month
var dateString = dateInt as! String
I have tried several methods, including the following:
"\(dateInt)"
dateInt.description
dateInt as String
String(dateInt)
However, all of them tell me that "Int is not convertible to String", or, with an "!" after the "as", that "Int cast to String will always fail". Does anyone have a way around this?