iPhone:如何从另一个控制器类访问View控制器类中的数据? [英] iPhone: How I can Access Data in a View Controller Class from Another Controller Class?

查看:68
本文介绍了iPhone:如何从另一个控制器类访问View控制器类中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有一个Entry表单,其中有六个Text字段

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

  1. 名称:UITextField
  2. 出生日期:UITExtField
  3. 年龄:UITextField
  4. 地址:UITextField
  5. 电话号码:UITextField
  6. 图片:UIIMageView

现在我想要的是我希望所有这些字段的值都在其他ViewController类的相同字段中.怎么可能.

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..

特别鸣谢

推荐答案

您可以通过在委托类中实现getter和setter来实现.

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

在代理.h文件中

包括UIApplication委托

Include UIApplication delegate

 @interface DevAppDelegate : NSObject <UIApplicationDelegate>

 NSString * currentTitle;

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

在Delegate实现类.m

In Delegate implementation class .m

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

}

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

因此,要评估的变量是通过setters方法和要在其中放置字符串的类在currentlink字符串中设置的,只需使用getter方法即可.

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.

这篇关于iPhone:如何从另一个控制器类访问View控制器类中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆