更新时间:2022-04-21 22:44:52
在接口中声明字符串并创建一个属性:
In the interface declare the string and make a property:
@interface MyViewController : UIViewController {
NSString *string_i_want_to_set;
}
@property (nonatomic, retain) NSString *string_i_want_to_set;
@end
在实现中合成@implementation之后的字符串MyViewController就像这个:
In the implementation synthesize the string after @implementation MyViewController like this:
#import "MyViewController.h"
@implementation MyViewController
@synthesize string_i_want_to_set;
// OTHER CODE HERE...
@end
然后当您分配/初始化视图控制器时,您可以设置如下属性:
Then when you alloc/init the view controller you can set the property like this:
MyViewController *myVC = [[MyViewController alloc] init];
myVC.string_i_want_to_set = @"...."
希望这能为您提供更多细节。
Hope this gives you more detail.
谢谢
James
Thanks James