Hi all, I have a function that worked perfectly in Xcode 7 written for iOS 9 but when I try to get it to work in Xcode 8 Beta 4 written for iOS 10 converted to Swift 3 syntax I get an error "Extra argument in call"
I will show my working code first then the broken code:
Swift 2:
Swift 3:
This is the line I get the error:
Any help would be much appreciated
I will show my working code first then the broken code:
Swift 2:
Code:
func getTime() -> (hour:Int, minute:Int, second:Int) {
let currentDateTime = NSDate()
let calendar = NSCalendar.currentCalendar()
let component = calendar.components([.Hour,.Minute,.Second], fromDate: currentDateTime)
let hour = component.hour
let minute = component.minute
let second = component.second
return (hour,minute,second)
}
Swift 3:
Code:
func getTime() -> (hour:Int, minute:Int, second:Int) {
let currentDateTime = NSDate()
let calendar = NSCalendar.current
let component = calendar.component(.hour, .minute, .second, from: currentDateTime)
let hour = component.hour
let minute = component.minute
let second = component.second
return (hour,minute,second)
}
This is the line I get the error:
Code:
let component = calendar.component(.hour, .minute, .second, from: currentDateTime)
Any help would be much appreciated