Japa
Japa

Reputation: 632

Multiple cells with multiple textfields to core data attributes

I have a tableview with 9 cells and in each cell i have at least 2 textfields. Each cell has a label, and the textfields.placeholder are the same in each cell:(example foto below)

enter image description here

I already created the entities in core data (which are the labels) and the attributes for each one ( which are the textfields.placeholder):

enter image description here

My question is, how can i set the textfield.text to each attribute in each entity? how to distinguish the textfields?....i don´t think that the IF statment is the best approach ( it would be a LOT!!), and the other problem is the cells are dynamic ( so the user can add more kind of trousers for example)...

Any ideas would be most appreciate... i´m really stuck!.

Thanks in advance.

I´ve been reading a little, but i´m having trouble understanding something: When you say "you can set an object for each cell" are your referring to the classes that core data automatically creates for each entity(when you hit subclass NSmanageobject button),and then i should bind the texfields from each cell to an object of each entity class??.I already have the classes that are referring to each cell, and then i think i should be doing this: Trousers *trouse = [NSEntityDescription insertNewObjectForEntityForName:@"Trousers" inManagedObjectContext:self.managedObjectContext]; trouse.nameProduct =Textfield.text.and this is the part i don´t no the best approach, because i have more than one textfield in each cell(and i din´t make them property´s of my view) and doing like this, it will be an enourmous amount of work! Can you help me understand better?.

Upvotes: 1

Views: 457

Answers (1)

Abizern
Abizern

Reputation: 150605

If you are using CoreData with a table view you should be hooking up model objects to the UI using NSFetchedResultsController

Have a look at the documentation and examples for this. It's designed to make this sort of thing less painful.

Upvotes: 1

Related Questions