如何将NSString发送到另一个视图控制器 [英] How to send an NSString to another view controller
本文介绍了如何将NSString发送到另一个视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个IBAction,当触发时调用另一个视图控制器中的另一个方法(APICallsViewController)。我也希望将该方法发送给NSString(消息)
I have an IBAction that when triggered calls another method in a different view controller ( APICallsViewController). I'm looking to also send that method an NSString (message)
这里是我的IBAction,推送到APICallsViewController以及NSString消息。我的问题可能是如何在其他视图控制器的方法中获取该NSString的内容。
here's my IBAction with the push to the APICallsViewController and also the NSString message. My question might be how do I grab the contents of that NSString in the other view controller's method.
感谢您的帮助
-(IBAction) someMethod{
APICallsViewController *apiViewController = [[APICallsViewController alloc] init];
[self.navigationController pushViewController:apiViewController animated:YES];
NSString *message = [NSString stringWithFormat:@"Check out %@", nameLb.text];
[apiViewController apiGraphUserCheckins];
[apiViewController release];
}
推荐答案
这样做APICallsViewController.h中的代码
do this code in APICallsViewController.h
@interface APICallsViewController : UIViewController{
NSString *strMessage;
}
@property(nonatomic,retain) NSString *strMessage;
@end
APICallsViewController.m
APICallsViewController.m
@synthesize strMessage;
- (void)viewDidLoad {
Nslog(@"%@",strMessage);
}
-(IBAction) someMethod{
APICallsViewController *apiViewController = [[APICallsViewController alloc] init];
[self.navigationController pushViewController:apiViewController animated:YES];
NSString *message = [NSString stringWithFormat:@"Check out %@", nameLb.text];
apiViewController.strMessage=message;
[apiViewController apiGraphUserCheckins];
[apiViewController release];
}
这篇关于如何将NSString发送到另一个视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文