PDA

View Full Version : Returning "Add" data to TableView




GVKoenig
Aug 23, 2010, 06:46 PM
Hello to all,

I need help returning data entered into a text field so that I can insert it into a table view.

The way I am going about this so far is akin to the 'iPhoneCoreDataRecipes' sample code. However, I am looking for a 'simpler' solution. I have all of my code set up to present the user with a modal view once they hit an 'Add' button. After this they are presented with a simple textField. My problem is in my 'save' method. I am not sure how to return it to my RootViewController so that it can be added to my tableView.

My goal is to start with an empty table and be able to add rows one at a time.

Any help or direction to sample code would be great.

Cheers



ianray
Aug 24, 2010, 01:16 PM
I have all of my code set up to present the user with a modal view once they hit an 'Add' button. After this they are presented with a simple textField. My problem is in my 'save' method. I am not sure how to return it to my RootViewController so that it can be added to my tableView.

Hi! You say "return it"... are you asking how to give textField.text to a different object?

GVKoenig
Aug 24, 2010, 05:18 PM
i want to be able to take what was put into the text field and update the tableView with it.

The tableView will start empty and will be added to via the text field.

my issue is with my 'model' data; i am not sure how to go about making a NSMutableArray object so that I can save data to it and then make it accessible to my tableView.

robbieduncan
Aug 24, 2010, 05:23 PM
The absolutely simplest way is to make it a property of your application delegate object. That's available everywhere via the UIApplication singleton object.

south8212
Aug 24, 2010, 10:30 PM
#import the .h file that your array is declared in into your rootview controller. Or if you need to make this variable accessible throughout the entire app, declare the array in the app delegate.

Sykte
Aug 26, 2010, 09:05 AM
Considering your rootViewController is the parent of the modal view. Create a protocol in your modal view and setup your rootViewController as the delegate object. Then message the delegate within the action of your add button on your modal view. The message to the delegate should pass the information you want.