Passing variable to another view (using Utility template)
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!
there are different ways to pass one variable to another view as:
1) Crate a global variable in appDelegateClass:
- In appDelegate.h crate a vriable as NSString *str with property
- In appDelegate.m syntheses it.
In View1 set this variable as:
yourAppDelegate *appdelegate= [[UIApplication sharedApplication] delegate];
appdelegate.str= @"some string";
- 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.
精彩评论