Reeplayed
Reeplayed

Reputation: 23

Saving data to be shown later

I'm new at iOS development and I'm following (and modifying) this tutorial: Table View Tutorial

What I am trying to do is the following. Once a user has selected what she/he wants in the UITableView, it appears a detailed view with a "Add to order" button. Labels are populated through Core Data.

I'm not sure how to save description and quantity (as represented in the figure) and create an order view which displays (later on) all the selections the user has made. Any ideas?

screenshot

Any help would be greatly appreciated. Thank you in advance.

Upvotes: 1

Views: 102

Answers (2)

Lorenzo B
Lorenzo B

Reputation: 33428

If you want to save data that could be retrieved later, you can save in two different ways.

In the first case you could save data using (for example) PropertyList mechanism. Data are saved in flash memory (in iOS filesystem and not in memory).

In the second way, instead, you could create a Singleton class that saves data in memory. Only one istance can exist during application execution. In this case, data are not saved in a permanent way like the first method.

In both situations you can save and retrieve data from every point of your app. Obviously the first method could be considered more robust than the first one. If the application crashes at some point data aren't lost.

Hope it helps.

Upvotes: 0

rishi
rishi

Reputation: 11839

You can create a model that contains all this information, something like -

interface MyOrder {

}

 @property(nonatomic, retain) NSString *name;
 @property(nonatomic, retain) NSString *description;
 @property(nonatomic, assign) NSInteger quantity;

Now where u want to save it, create an object of this model and save data in the objects. If you want multiple orders then you may create array of orders. Now after this u can pass these object to next view controllers as a form of property of that view controller.

Upvotes: 1

Related Questions