Extra argument in call

Discussion in 'Mac Programming' started by Futhark, Aug 6, 2016.

  1. Futhark macrumors 65816

    Futhark

    Joined:
    Jun 12, 2011
    Location:
    Northern Ireland
    #1
    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:

    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 :)
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2

Share This Page