passing the value from one class to other class

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 08:39:18
Rajneesh071

Just do few thing in your code you will get you string

1 :->

Declair your DetailsOfPeopleViewController globally.

i.e. in .h

DetailsOfPeopleViewController *detail  

2 :->

in your viewDidLoad alloc it in memory

detail=[[DetailsOfPeopleViewController alloc] init];  

3 :->

Just declare your string property to copy

@property(nonatomic,copy) NSString *testPersonNotesStr;  

or

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

Follow my answer i have NSString value in addViewController and i want to display this value in UILabel of DetailsViewController

You make it a property, so possibly try using the set method. Also, you need to init your ViewControlelr before setting the value. So:

DetailsOfPeopleViewController *detail=[[DetailsOfPeopleViewController alloc] init];
[detail setTestPersonNotesStr:[NSString stringWithFormat:@"%@",txtView.text]];

And I do not see where you actually display this view, you have to be displaying the same instance of this view to actually see the value.

use delegates to pass values use this reference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!