What is PersistentStorageSerializable?

PersistentStorageSerializable is a protocol for automatic serialization and deserialization of Swift class, struct or NSObject descendant object into and from User Defaults or Property List file.

The adopting type properties must be of property list type (String, Data, Date, Int, UInt, Float, Double, Bool, Array or Dictionary of above). If you want to store any other type of object, you should typically archive it to create an instance of Data. The URL properties can be stored in User Defaults storage but not in Plist storage. In the last case, you have to archive it to/from Data.

The PersistentStorageSerializable protocol provides default implementations of init(from:) initializer and persist() function. The library defines two classes of PesistentStorage protocol: UserDefaultsStorage and PlistStorage. Object of one of those types is passed as the argument when calling to init(from:) initializer to specify which storage to be used for serialization/deserialization.

Functions of the PersistentStorageSerializable protocol traverses the adopting type object and gets/sets it’s properties values via Reflection library. The NSObject class descendant properties values are get/set via KVC.

Overview

  • Pricing: Free
  • Resource Link: https://github.com/IvanRublev/PersistentStorageSerializable
  • Resource Maker: Ivan Rublev
  • Mobile Platform Destination: iOS Apps
  • Mobile Platform Support: Native iOS
  • Programming Languages: Swift
  • iOS Versions Supported: iOS 8.0+, iOS 9.0+, iOS 10.0+, iOS 11.0+, iOS 12.0+
  • CocoaPods: PersistentStorageSerializable
  • Carthage: IvanRublev/PersistentStorageSerializable