1

I´m struggling a lot to find a good solution, and searched a lot also, but i can´t find anything similar with what i want, so i hope anyone can help me:

I have two tableviews, in the first one i already have custom cells, and each cell has two textfields, one textfield for the product name, and the other one to it´s price, then if the user want´s, he can had more cells which he will insert more products with their respective price.

The second tableview has also two textfields, in the first textfield he will choose one product( inserted in the first tableview)with a pickerview, and when he chooses the product, i want the respective price to appear in the other texfield.

My question is, should i be using core data? or another type of persistence? and is it possible to assign the values of the texfields to the atributes created in a model of core data?

Japa
  • 632
  • 7
  • 30

1 Answers1

0

You can use core data for your requirement and you can assign the data to textfields.

prashant
  • 1,920
  • 14
  • 26
  • Thank you for your answer prashant, but is the core data the best approach for this? can´t i just use an array that will be loaded every time the app starts? and, is it possible to add core data? (because i din´t when started making the app) – Japa Sep 10 '12 at 13:40
  • 1
    Yes you can do it with array and save it NSUserDefaults or plist but its only best approach when you have to deal with small size of data. If you have bigger size of data then you should use core data. – prashant Sep 10 '12 at 14:18
  • I don´t know if the user will add 50 products, or 100 products or more...Can you give me a little example of assigning textfields.text to an core data attributes? thank you again – Japa Sep 10 '12 at 14:36
  • 1
    Product *product = (Product *)[NSEntityDescription insertNewObjectForEntityForName:@"Product " inManagedObjectContext:managedObjectContext]; [product setProductName:[productNameTextField.text]]; NSError *error; if(![managedObjectContext save:&error]){ //This is a serious error saying the record //could not be saved. Advise the user to //try again or restart the application. } – prashant Sep 10 '12 at 16:15