Setting parent view controller's property doesn't actually set it, quite stumped

Discussion in 'iOS Programming' started by Legolover64, Mar 23, 2010.

  1. Legolover64 macrumors regular

    Feb 24, 2008
    Hi all!

    The value property in my parent view controller's property is a float, and I'm using the @property (readwrite, assign) specifier. I'm synthesizing the properties. Here's what I was just playing with:

    ((myViewController*)self.parentViewController).otherViewController.value = 1.0; 
    assert(((myViewController*)self.parentViewController).otherViewController.value == 1.0); 
    This assert statement fails. I'm really confused why it's happening. Any ideas? The property is a float.

    Thanks so much for any and all help!
  2. xsmasher macrumors regular


    Jul 18, 2008
    Either parentViewController or otherViewController is nil. I'd log them both to find out which, and then go find out why they weren't set.
  3. Legolover64 thread starter macrumors regular

    Feb 24, 2008

    Turns out both of those values are nil. I looked up the documentation for parentViewController, and it's only not nil if I'm using a navigationController or something similar. Sadly I can't see to be able to write to the view controller which contains my current view controller (parentViewController is readonly).

    Is there some other way to access the view controller in which this view controller is rendered?


Share This Page