Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
388 views
in Technique[技术] by (71.8m points)

iphone - 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.

It's in AddViewController.

NSLog(@"Am Currently at %@",locatedAt);

DetailsOfPeopleViewController *details=[DetailsOfPeopleViewController alloc];
   details.testAddressStr=[NSString stringWithFormat:@"%@",locatedAt];

details.testAddressStr is displaying the value here, but it's not passing this value to DetailsViewController.

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.

In DetailsViewController.h:

NSString *testAddressStr;

@property(nonatomic,strong) NSString *testAddressStr;
@property(nonatomic,retain)IBOutlet UILabel *addressLabel;

In DetailsViewController.m:

 [addressLabel setText:testAddressStr];

Am also trying it this way:

addressLabel.text=[NSString stringWithFormat:@"%@",testAddressStr];

I'm not really getting where I'm making a mistake...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can send data using NSUserDefault

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);  

:)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...