Reputation: 1
Is there any other solutions in iOS for saving the NSDate in one ViewController and showing it in a label in another ViewController rather than NSUserDefaults? I have 2 viewControllers in my project which one of them is DatePicker and another is a normal ViewController with a label.I want to show the time with DatePicker chosen in that label and I use NSUserDefaults.I am curios is there any other solution for this matter?Thanks in advance.
Upvotes: 0
Views: 136
Reputation: 713
Core Data can be used instead of NSUserDefaults. Core Data is better, though, for larger amounts of data, so for your case, NSUserDefaults is the best option.
Core data is great for relationships and has a nice interface for adding entities and relationships.
It uses key value coding (setValue:ForKey: like NSDictionary) and objects from core data are subclasses of NSManagedObject.
Here is a nice tutorial: http://www.raywenderlich.com/934/core-data-tutorial-for-ios-getting-started
Upvotes: 1
Reputation: 7343
You can use a singleton class (e.g. DataManager
), and you could keep the selected date here if you have no direct segue between these 2 UIViewControllers
. if you do, just add a property
and set it when you present the controller. However, these won't persist between app launches, so for that you would need the NSUserDefaults
Upvotes: 0