2

I'm trying to initialise an NSTimeZone object like this:

var timezone = NSTimeZone.init(name: "Europe/Moscow")

instead of nil or a legit locale value - I get "unable to read data" in xCode's debugging tool

enter image description here

I got the timezone string ("Europe/Moscow") via NSTimeZone.knownTimeZoneNames()

I'm using xCode 7

What am I doing wrong?

milo526
  • 5,012
  • 5
  • 41
  • 60
David Schmoecker
  • 567
  • 3
  • 8
  • 17

3 Answers3

0

Haven't used that class before, but I'm guessing it should be let timezone = NSTimeZone(name : "")? Never seen a class initialized in that way.

Naoto Ida
  • 1,275
  • 1
  • 14
  • 29
0

Its working fine for me , use let instead of var.Check below enter image description here

For reference Swift NSDate UTC time and local time

Community
  • 1
  • 1
IamAnil
  • 496
  • 5
  • 19
  • Hm - can you try running it with the IPhone 5 simulator? When running IPhone 6 simulator I get it correct aswell (regardless of using let or var) – David Schmoecker Oct 13 '15 at 11:43
0

As pointed out in the comments - the variables view was just wrong - a print() resulted in the correct output.

Running an iPhone 6 Simulator instead of an iPhone 5 simulator gives the expected results.

David Schmoecker
  • 567
  • 3
  • 8
  • 17