0

this is the code for.m class of first viewcontroller[][1]I had tried accessing value of IVAR of one viewcontroller to another viewcontroller by making use of property , but i am getting null value.

please let me know how to get value displayd in my secondviewcontroller.

enter image description here

trungduc
  • 11,926
  • 4
  • 31
  • 55

1 Answers1

1

You are doing the right way to get value of property. But you need to make sure myString has been assigned a value in init method of ViewController.

Try in ViewController.m:

- (instancetype)init {
    self = [super init];

    if (self) {
        self.myString = @"My String";
    }

    return self;
}

Beside of it, make sure that myMetod of SecondViewController is called. If myMetod is called, "Print value My String" will be printed.

trungduc
  • 11,926
  • 4
  • 31
  • 55