views:

25

answers:

1

Hello All. I am having trouble accessing a declared property and I think I am missing something fundamental about the nature of properties and perhaps view controllers. Here's what I'm doing so far:

  • declaring a property "myPhone" in a root view controller called RootViewController.

  • grabbing a phone number from a modally presented people picker

  • setting "myPhone" to the value from the people picker (from within shouldContinueAfterSelectingPerson of ABPeoplePickerNavigationController)

  • trying to access "myPhone" from another modally presented view controller

"myPhone" continues to NSLog to null despite trying every permutation of self.myPhone, super, RootViewController, etc. to try and access the value I set.

What am I missing?

A: 

OK, I needed to pass the property to the modally presented view controller when creating it:

anotherviewcontroller.myPhone = myPhone;

Then, oddly enough, calls to "myPhone" found their way to the data when called from within the modally presented view controller.

Perhaps one of you wizards can elaborate on why this was the case?

Hank