0

I have a mini-workout application, the root is a UITableViewController and each cell segues to a specific TVC that has its own specific settings denoted by UISliders and UISegmented Controls (As shown by the image).

Of course when I navigate back to the root controller and back again to the specific cell workout, the UIElements forget the previously entered values.

However setting up Entities and Attributes does not seem like the most efficient way to remember the UISettings? Should I use encoder decoder, write to a file?

There must be an efficient way to do this. Thanks.

Too many UI Settings

Cescy
  • 1,921
  • 3
  • 18
  • 21

1 Answers1

0

First create an object call it anything you like, example UIValues.
Let this object have the properties that you want to save:

@property (assign) CGFloat pushupsToday;

....

Create this object and have a strong reference to it. For example in your appDelegate or your RootViewController.

let your viewControllers share this object when you are trying to push new viewController example newViewController.uiValues = self.uiValues.

If you want to save this value to disc, then you have to make to encode and decode values.

Basheer_CAD
  • 4,908
  • 24
  • 36
  • Because I have multple workout routines, would you say encoding and decoding is a better way to persist all these UIValues than setting up attributes in Core Data? – Cescy Feb 20 '14 at 10:07
  • I don't think passing the data up and back is the best way – Cescy Feb 20 '14 at 10:08
  • That depends on the amount of data that you want to save, if you have a lot of them, then of course coreData is the choice. But any way you need an object to save the values and pass them to viewControllers to update there UI states. @CescSergey – Basheer_CAD Feb 20 '14 at 10:10
  • yeah I expect to add more workout routines with more specific UISettings, core data is the way to go thanks. – Cescy Feb 20 '14 at 10:11