How can I return 3 separate data values ββof the same type (Int) from a function in swift?
I'm trying to return the time of day, I need to return the Hour, Minute and Second as separate integers, but all in the same direction from the same function, is this possible?
I think I just don't understand the syntax for returning multiple values. This is the code I use, I have problems with the last (return) line.
Any help would be greatly appreciated!
func getTime() -> Int { let date = NSDate() let calendar = NSCalendar.currentCalendar() let components = calendar.components(.CalendarUnitHour | .CalendarUnitMinute | .CalendarUnitSecond, fromDate: date) let hour = components.hour let minute = components.minute let second = components.second let times:String = ("\(hour):\(minute):\(second)") return hour, minute, second }
function return swift
OllieGreen Dec 17 '14 at 17:18 2014-12-17 17:18
source share