我在addViewController中有NSString值,并且我想在DetailsViewController的UILabel中显示此值 [英] i have NSString value in addViewController and i want to display this value in UILabel of DetailsViewController
问题描述
我是编程的新手.任何帮助将不胜感激.
I am newbie to programming. Any help could be greatly appreciated.
它在AddViewController中.
It's in AddViewController.
NSLog(@"Am Currently at %@",locatedAt);
DetailsOfPeopleViewController *details=[DetailsOfPeopleViewController alloc];
details.testAddressStr=[NSString stringWithFormat:@"%@",locatedAt];
details.testAddressStr
在此处显示值,但没有将此值传递给DetailsViewController.
details.testAddressStr
is displaying the value here, but it's not passing this value to DetailsViewController.
locatedAt
的值显示在AddViewController中.当我尝试在DetailsViewController类的UILabel中显示此值时,它不在标签中显示该值.
The value of locatedAt
is displaying in the AddViewController. When I try to display this value in UILabel of DetailsViewController class it's not displaying that value in the label.
在DetailsViewController.h中:
In DetailsViewController.h:
NSString *testAddressStr;
@property(nonatomic,strong) NSString *testAddressStr;
@property(nonatomic,retain)IBOutlet UILabel *addressLabel;
在DetailsViewController.m中:
In DetailsViewController.m:
[addressLabel setText:testAddressStr];
我也尝试这种方式:
addressLabel.text=[NSString stringWithFormat:@"%@",testAddressStr];
我并没有真正弄错我的地方...
I'm not really getting where I'm making a mistake...
推荐答案
您可以使用 SetValue
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[NSString stringWithFormat:@"%@",txtView.text]; forKey:@"testPersonNotesStr"];
[defaults synchronize];
GetValue
testPersonNotesStr = [[NSUserDefaults standardUserDefaults] objectForKey:@"testPersonNotesStr"];
NSLog(@"PERSON NOTE is........ %@",testPersonNotesStr);
:)
这篇关于我在addViewController中有NSString值,并且我想在DetailsViewController的UILabel中显示此值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!