0

I want to fill a tableView with some data (Strings), that I save in another View/ViewController.

My viewDidLoad of the SaveViewController:

NSString *savestring = @"Test: This is a test!"; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:savestring forKey:@"savedstring"]; [defaults synchronize]; 
  1. Is this a good way to save data? (It's very easy so I am using it at the moment)

Now I am having another View (TableView), that should fill with this string dynamically. (I want to add the date and some string, it should be something like a training journal)

2 . How can I do this? Should I change my "saving" ?

2
  • Are you asking about "saving" it during the current session, or do you want to persist this data so it is available if the app quits and restarts? Commented Aug 8, 2014 at 15:18
  • I want to persist this data :) Commented Aug 8, 2014 at 15:21

2 Answers 2

1

No NSUserDefaults is not a good place to save data with the exception of storing a few user preferences. You should look into using Core Data for your general storage needs.

You can also save to plists which depending on your data can be simpler e.g. you just need to store a single dictionary.

Sign up to request clarification or add additional context in comments.

Comments

1

You can sore this changes in some model object. Than you can send this object using delegate, or u can create singleton app manager with general model object. If you want to save this data to database, you should read about CoreData.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.