user1406716
user1406716

Reputation: 9705

Cannot convert value of type '(NSDate) -> NSTimeInterval to expected argument type 'Double'

Docs say that NSDate.timeIntervalSinceDate() returns NSTimeInterval which is a typealias for a Double.

I am not 100% sure what a typealias is. Basically, if my function needs a Double, how can I get the Double from NSTimeInterval.

var t_start: NSDate = NSDate()


//**THIS IS WHERE THE ERROR IS**
mCloud.saveSessionDuration(PFUser.currentUser()!, duration:     NSDate.timeIntervalSinceDate(t_start))

The function saveSessionDuration is as follows:

func saveSessionDuration(usr: PFUser, duration: Double) {
    //do something
}

Upvotes: 1

Views: 1140

Answers (1)

CodeHelp
CodeHelp

Reputation: 1328

timeIntervalSinceDate is not a class method. Maybe you can try

NSDate().timeIntervalSinceDate(t_start)

Upvotes: 1

Related Questions