0 Replies
      Latest reply on Sep 1, 2016 3:59 PM by 3DTOPO
      3DTOPO Level 1 Level 1 (0 points)

        I am attempting to store and restore a custom UIView using the methods encodeRestorableStateWithCoder and decodeRestorableStateWithCoder. I have assigned a unique string to the UIView's restorationIdentifier property first thing in the only init method in use. Note that it is a custom init method - I'm not sure if that makes a difference, for instance this is how I am allocating and assigning the property:


        init(frame: CGRect, menuGroups: Array) {
          super.init(frame: frame)
          restorationIdentifier = "TDTOilistMenu"


        Although I am not using init?(coder aDecoder: NSCoder) I have that defined as well:

        required public init?(coder aDecoder: NSCoder) {
          super.init(coder: aDecoder)
          restorationIdentifier = "TDTOilistMenu"


        Anyways, the method encodeRestorableStateWithCoder is being called when the app is put into the background, but decodeRestorableStateWithCoder is never called when the app is launched. I am terminating the app (in Xcode) after putting the app in the background, so it should be.


        Per Apple's documentation, the owning ViewController also has a unique identifier for its' restorationIdentifier property:



        Note that I have tried setting the view's restorationIdentifier property from using the owning View Controller's restorationIdentifier property (directly after initialization), but that makes no difference; the UIView's decode method is still not callled.


        What do I have to do to ensure decodeRestorableStateWithCoder is called?