passing the value from one class to other class

前端 未结 3 724
无人共我
无人共我 2021-01-26 11:17

I am facing the problem in displaying the value of string of AddNotesViewController Class , in the Label of the DetailsOfPeopleViewController.

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-26 11:58

    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

提交回复
热议问题