-2

For Example : I have two ViewController, A and B , A have @Property(copy,nonatomic)NSString *test;
if A push to B How can update test of A, I have see some answer about Double ** and point.but I don‘t know 。Thank you!

Gourav Joshi
  • 2,419
  • 2
  • 27
  • 45

1 Answers1

1

You can use singleton class for that. Use AppDelegate for that.

Make a NSString property in AppDelegate and update the value of this NSString from AppDelegate when you will move from A to B.

In viewWillAppear() of A assign the value of NSString from AppDelegate to that in A(test)

In AppDelegate.h

@property (strong, nonatomic) NSString *value;

In ViewController A

#import "AppDelegate.h"


-(void)viewWillAppear:(BOOL)animated
{
    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;

    self.test = appDelegate.value;

}

When push to ViewController B:

You can assign new value to AppDelegate NSString as:

AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;

appDelegate.value = @"YOUR NEW VALUE";
SNarula
  • 548
  • 3
  • 16