views:

379

answers:

2

Hey ,

In my application I have one Entry form in which there are six Text fields

  1. Name :UITextField
  2. Date of Birth :UITExtField
  3. Age:UITextField
  4. Address :UITextField
  5. Phone No :UITextField
  6. Image : UIIMageView

Now What I want is that I want all these fields value in the same fields of other ViewController class. How it could be possible .

Please help me I really need help for this..

Special Thanks in Advance

+1  A: 

You can achieve that by implementing getter and setters in the delegate class.

In delegate .h file

Include UIApplication delegate

 @interface DevAppDelegate : NSObject <UIApplicationDelegate>

 NSString * currentTitle;

- (void) setCurrentTitle:(NSString *) currentTitle;
- (NSString *) getCurrentTitle; 

In Delegate implementation class .m

-(void) setCurrentLink:(NSString *) storydata{
currentLink = storydata;

}

-(NSString *) getCurrentLink{
if ( currentLink == nil ) {
currentLink = @"Display StoryLink";
}
return currentLink;
}

So the variable you to assess is set in the currentlink string by setters method and class where you want the string ,just use the getter method.

Warrior
+1  A: 

What you really need is a data model object.

A data model is an object of dedicated class that stores and logically manipulates the applications data. It should be an entirely separate class from either the views or the view controllers. It should universally accessible within the app preferably as a singleton.

(Warrior's solution is a lightweight solution that turns the app delegate into the data model object. It will work for small, quick and dirty apps. It will breakdown as the data grows more complex.)

In your case, controller A would write the collected data to the data model and then it would close its view. Controller B would upon activating, check the data model and read out the information it needed.

The beauty of using the data model is that it has the flexibility of an old style global variable combined with the safety of using a class dedicated to to maintaining the data's integrity.

For more details see: http://stackoverflow.com/questions/2241893/pattern-for-ownership-and-references-between-multiple-controllers-and-semi-shared/2242012#2242012

and

http://stackoverflow.com/questions/2336976/simple-mvc-setup-design/2337375#2337375

TechZen