Daniel Granger
Daniel Granger

Reputation: 1334

How to pass object between views with a storyboard Created Tab Bar Controller

I have 2 views controlled by a tab bar view controller created by the template Xcode 4 gives out using the storyboard.

My first view on the first tab is a data entry page, my second view on the second tab graphs this data. I have an object where the first view stores this data. How do I not only pass this object to my second view but also ensure it gets updated when someone changes one of the UITextfields on the first view?

Many thanks

Upvotes: 4

Views: 1115

Answers (1)

rob mayoff
rob mayoff

Reputation: 385920

Put the data object in a property of your application delegate, or in a global variable. In your data entry page's view controller, add an IBAction method for each text field. In the action method, update the corresponding field of data object. In the storyboard, connect each text field's "Editing Did End" or "Value Changed" event to the appropriate IBAction method.

Upvotes: 2

Related Questions