I'm wondering if there is some new and awesome possibility to get the amount of days between two NSDates in Swift / the "new" Cocoa?
E.g. like in Ruby I would do:
(end_date - start_date).to_i
I'm wondering if there is some new and awesome possibility to get the amount of days between two NSDates in Swift / the "new" Cocoa?
E.g. like in Ruby I would do:
(end_date - start_date).to_i
Then use it like
Here is my answer for Swift 3:
The things built into swift are still very basic. As they should be at this early stage. But you can add your own stuff with the risk that comes with overloading operators and global domain functions. They will be local to your module though.
You could use the following extension:
Then, you can call it like this:
I'm going to add my version even though this thread is a year old. My code looks like this:
I hope it helps someone.
Cheers,
Swift 3 - Days from today until date
Call function like this