我必須將字符串值從一個視圖傳遞到其他視圖中的標籤。但是當我做這樣的事情時,標籤值是空的。無法理解我出錯的地方?這裏是我的代碼:當在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來傳遞值 –