Reputation: 12752
I'm new to iOS development and I'm having a hard time understanding the following.
On a MacBook Pro w/ Yosemite 10.10.2 and Xcode 6.1.1, I have the following code:
let unixDateString = "1419382818000"
println(unixDateString.toInt()!)
When I run this code with the simulator, any device above and including the iPhone 5S works as expected (no crash).
However for the iphone5 and iphone 4S, the program crashes and the debugger tells me the value of unixDateString.toInt() is nil. It also crashes with the ipad2 and ipad retina but not with the ipad air.
What's going on ?
Upvotes: 0
Views: 56
Reputation: 154583
The iPhone5 and below are 32-bit devices, so Int
is 32-bit and your string is too large to fit in an Int
so toInt
fails and returns nil
.
Upvotes: 1