Search code examples
core-dataios7nstimezone

Store NSTimeZone in Core Data


I tried to save NSTimeZone as transformable type, but it doesn't work seems due to it conforms to NSSecureCoding.

Is it any other alternatives?


Solution

  • If the TimeZone has a defined name, you can store that as a string. It may not have a name if you manually constructed the timeZone based off a GMT offset.

    ... So you could store the GMT offset if you wanted, but then you would lose any of the DST information associated with a named timezone.

    Probably the best way is to store the data. That should contain the information necessary to reconstruct the appropriate NSTimeZone instance.