0

I have an UIScrollView object that contain other views. There are UIViewController(s) that user can create in runtime and puts they views on UIScrollView. In its turn they store also different view.

So I suppose that I can use NSCoding for storing user interface in NSUserDefaults. But maybe another way will be most beautiful, for example if I will have data model of these views and if I need they I will recreate it using data model instead NSCoding that will store all my object in storage.

Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277

1 Answers1

3

I wouldn't store any user interface element itself. Nor would I store whole model objects. The best way would be to store the minimum that is required to restore the (data) model objects.

You might need to create a 'tree of stored data' so that each view controller can restore it's own children and pass them the stored data so they can do the same etcetera.

Then when the time comes to restore you just need to rebuild the data model using the stored values and hook them up to the user interface.

Rengers
  • 14,911
  • 1
  • 36
  • 54