Reputation: 798
I am novice in iOS.. so I have question. I have 2 views in a UITabBar. one is registration and second one is details.
I want to pass textfields data from registration view to details view. registrations view containing textfields .
how can I do it??
Thankss
Upvotes: 0
Views: 860
Reputation: 4174
I usually use the App Delegate for things that need to be passed around like that.
Create an instance variable in your app delegate to store the value you want to share, e.g.:
NSString *name;
In your Registration view, store the value into the instance variable in your app delegate:
AppDelegate *ad = (AppDelegate *)[[UIApplication sharedApplication] delegate];
ad.name = self.nameField.text;
Then in your Details view you can access it by something like:
AppDelegate *ad = (AppDelegate *)[[UIApplication sharedApplication] delegate];
self.nameLabel.text = ad.name;
Alternatively, you could keep a pointer to your Registration view in your app delegate and then just reference that from your Details view and access the text fields directly.
Upvotes: 2