views:

245

answers:

1

I have two customized cells in an iphone UITableViewController and would like to capture the data in one cell into another.....

I am currently unable to post images and pls assume the following points.

There are two custom UITableViewcells 1) Notes Textfield in one customcell 2) Submit button in another text field. Now i want to pass data typed in the notes textfield to be available when I click the Submit button.... Is this possible? Please help....:(

A: 

In general you should store your data separate from views. So if you have some table controller there must data objects like array or dictionary or array of dictionaries. And when you click submit you should get associated data object and work with it.
In your case when textfield lose focus you must get textfield value and store it in your data store.

UPD: It not very clean but can help at first

- (void) textFieldDidEndEditing: (UITextField *) textField {

    // At first need to get cell. findSuperviewWithClass is custom method to find proper superview object
    MyCellClass *cell = (MyCellClass*)[textField findSuperviewWithClass:[MyCellClass class]];

    // and indexPath for it
    NSIndexPath *index = [tableView indexPathForCell:cell];

    // tableData is NSArray of my objects
    MyDataObjClass *dataObj = [tableData objectAtIndex:index.row];

    dataObj.text = textField.text;

}
Skie
Hey Skie thanks for your quick reply.... Do you have any sample code or pointers that point to storing of data or retrieving them....
Mithun
Hi Skei, I got the two parts of getting the native cell and index path but not the MyDataObjClass.... What datatype it is? Is it just a .h file with collection of NSArray?
Mithun
It's your data object. It can be string, can be dictionary, can be any custom object. Which data you are using in tableView?
Skie
Hey Skie... Thanks for all your help.... I solved the problem with the help of static variables.....
Mithun