user6929247
user6929247

Reputation:

NSNumber & NSDate (swift 3)

I'm trying to create a timeStamp for sent/received messages to store inside of my database (firebase) and I'm not sure if I'm going about it correctly. Here's the line of code thats giving me an error:

error

Previously, I would write:

let timeStamp: NSNumber = Int(NSDate().timeIntervalSince1970))

but I'm getting the same error:

"Argument labels '(_:)' do not match any available overloads"

Upvotes: 0

Views: 1383

Answers (2)

revi
revi

Reputation: 45

timestamp: NSDate().timeIntervalSince1970 as NSNumber

Upvotes: 1

rmaddy
rmaddy

Reputation: 318794

You can't assign an Int value to an NSNumber variable. You need to create an NSNumber from the Int. And you need to specify the parameter label:

let timeStamp: NSNumber = NSNumber(value: Int(NSDate().timeIntervalSince1970)))

Of course you now don't need to specifically state the data type:

let timeStamp = NSNumber(value: Int(NSDate().timeIntervalSince1970)))

Upvotes: 2

Related Questions