如何将字符串值从一个视图控制器传递到另一个视图控制器 [英] how to pass a string value from one view controller to another view controller
问题描述
你是我对目标c的新手。我有一个登录视图控制器与.h,.m,.xib文件。
,成功登录后我需要转到第二页。
hi i am new to objective c. i have a login view controller with .h, .m, .xib files. and after successful login i need to go to the second page.
情况就是这样,我正在访问网络服务。为了验证用户,我将用户名和密码发送到Web服务,作为回报,我得到一个字符串值。
基于我需要显示第二个屏幕的字符串值的结果。
请帮助
The scenario is this, i am accessing web services. to authenticate the user, i send the username and password to the web service and in return i get a string value. based on the results of the string value i need to display a second screen. Please help
推荐答案
如果您只需要传递几个值,就可以将它们作为 init 方法。例如:
If you only need to pass just a few values you can make them parameters to the init method. For example:
-(id)initWithUserName:(NSString *)name andPassword:(NSString *)password {
self = [super init];
if (nil == self) {
return nil;
}
// display or store login info somewhere
[someLabel setText:name];
return self
}
否则如果您有很多您希望在下一个视图中使用的值与Morion的建议一起使用并单独创建一个类。
Otherwise if you have a lot of values you want to use in the next view go with Morion's advice and make a separate class.
这篇关于如何将字符串值从一个视图控制器传递到另一个视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!