Returning "Add" data to TableView

Discussion in 'iOS Programming' started by GVKoenig, Aug 23, 2010.

  1. GVKoenig macrumors newbie

    Aug 6, 2010
    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.

  2. ianray macrumors 6502

    Jun 22, 2010
    Hi! You say "return it"... are you asking how to give textField.text to a different object?
  3. GVKoenig thread starter macrumors newbie

    Aug 6, 2010
    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.
  4. robbieduncan Moderator emeritus


    Jul 24, 2002
    The absolutely simplest way is to make it a property of your application delegate object. That's available everywhere via the UIApplication singleton object.
  5. south8212 macrumors 6502

    Oct 18, 2008
    #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.
  6. Sykte macrumors regular

    Aug 26, 2010
    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.

Share This Page