开发者

Passing variable to another view (using Utility template)

开发者_JAVA技巧

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:

  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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜