我必须将字符串值从一个视图传递到其他视图中的标签。但是当我做这样的事情时,标签值是空的。无法理解我出错的地方?这里是我的代码:当在iphone的其他视图中传递一个视图的字符串值时返回null?
在FirstViewController.m
SecondViewController *gp=[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:[NSBundle mainBundle]];
gp.d.text = [NSString stringWithFormat:@"%@", nam];
[self.view addSubview:gp.view];
[gp release];
在SecondViewController.h
@interface SecondViewController : UIViewController<NSXMLParserDelegate>
{
UILabel *d;
}
@property (nonatomic,retain) IBOutlet UILabel *d;
在SecondViewController.m @synthesize d;
- (void)viewDidLoad
{
NSString *urlString1 = [NSString stringWithFormat: @"http://192.168.0.108:8732/Design_Time_Addresses/ICloudServices/AppointmentService/json/GetProviders/?cid={%@}", [d text]];
}
但是这里d的值没有通过。为什么我不明白。我哪里错了?
使用NSString将值传递给第二个viewController。 –
视图控制器IBOutlet内存得到改变。所以使用NSString来传递值 –