Type 'TimeZone' has no member 'local' in Swift3 Type 'TimeZone' has no member 'local' in Swift3 ios ios

Type 'TimeZone' has no member 'local' in Swift3


By going deep into class hierarchy,have found NSTimeZone as public typealias, which open up access of NSTimeZone for us.

Inside TimeZone

public struct TimeZone : CustomStringConvertible, CustomDebugStringConvertible, Hashable, Equatable, ReferenceConvertible {    public typealias ReferenceType = NSTimeZone}

So by using below syntax error get disappear.

So below code will work.

For local time zone.

formatter.timeZone = TimeZone.ReferenceType.local

For default time zone.Use default with same syntax.

formatter.timeZone =  TimeZone.ReferenceType.default

For system time zone.Use system with same syntax.

formatter.timeZone = TimeZone.ReferenceType.system

Swift 3

You can use .current instead of .local.

TimeZone.current


Use this instead of .local in swift 3:

TimeZone.current