views:

31

answers:

1

Okay, so I'm obviously a newbie, but I need some help passing a variable to another view. I'm using the Utility Template in Xcode.

I think I have everything linking properly (including the proper header files and whatnot). Just don't know the proper syntax. Here's what I'm trying:

NSDate *time =[flipsideViewController.datePicker date];

If I run this in RootViewController.toggleView it works fine.

Any would would be greatly appreciated!

A: 

there are different ways to pass one variable to another view as:

1) Crate a global variable in appDelegateClass:

  1. In appDelegate.h crate a vriable as NSString *str with property
  2. In appDelegate.m syntheses it.
  3. In View1 set this variable as:

    yourAppDelegate *appdelegate= [[UIApplication sharedApplication] delegate];

appdelegate.str= @"some string";

  1. In view2 again crate a same object and retrieve value. NSString *myStr= appdelegate.str;

The another way is to define property in view2 and access it from View one.

iPhoneDev