将NSString从一个类传递到另一个类 [英] passing NSString from one class to the other
本文介绍了将NSString从一个类传递到另一个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个NSString从ViewController的UITextField。我的其他ViewController也将使用这个NSString。如何将此NSString传递给其他ViewControllers?
I have a NSString that is taken from a UITextField in a ViewController. Every of my other ViewController will use this NSString as well. How can I pass this NSString to others ViewControllers?
推荐答案
您想要一个属性
@interface MyViewController : UIViewController{
NSString *title;
}
@property (retain) NSString *title;
@end;
@implementation MyViewController
@synthesize title;
@end;
使用方式如下:
MyViewController *myVC = [[MyViewController alloc] initWithFrame:...];
myVC.title = @"hello world";
您应该熟悉内存管理
这篇关于将NSString从一个类传递到另一个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文