Help needed. I can’t create NSTimeZone (from ios) ...
# kotlin-native
j
Help needed. I can’t create NSTimeZone (from ios) on kotlin side. I’m trying it like this:
NSTimeZone().initWithName(tzName = "UTC")
but get nullpointerexception:
Copy code
Uncaught Kotlin exception: kotlin.NullPointerException
        at 0   greeting                            0x0000000103deb2e2 kfun:kotlin.Exception.<init>()kotlin.Exception + 50
        at 1   greeting                            0x0000000103deb212 kfun:kotlin.RuntimeException.<init>()kotlin.RuntimeException + 50
        at 2   greeting                            0x0000000103deb192 kfun:kotlin.NullPointerException.<init>()kotlin.NullPointerException + 50
        at 3   greeting                            0x0000000103dea4db ThrowNullPointerException + 59
        at 4   greeting                            0x0000000103dd757a kfun:org.greeting.Product.iosSpecificOperation()kotlin.String + 298
s
Calling
initWithName
methods is incorrect.
NSTimeZone()
is already initialized. A proper constructor a factory should be called instead:
Copy code
NSTimeZone.create(tzName = "UTC")
j
thanks!