Strange error: assignment of read-only variable 'prop.1386'

Discussion in 'iOS Programming' started by idelovski, Nov 12, 2011.

  1. idelovski macrumors regular

    Joined:
    Sep 11, 2008
    #1
    Can someone please explain this error: assignment of read-only variable 'prop.1386'

    I get it for the last line of this piece of code:

    Code:
    - (BOOL)goingBackwards
    {
       return (goingBackwardsFlag);
    }
    
    ...
    
    CATransition  *trans = [CATransition animation];
    
    trans.subtype = [self goingBackwards] ? kCATransitionFromLeft : kCATransitionFromRight;
    But, if I rewrite it like this I don't get the error and all is fine:

    Code:
    if ([self goingBackwards])
       trans.subtype = kCATransitionFromLeft;
    else
       trans.subtype = kCATransitionFromRight;
    Googling for prop.1386 didn't bring anything useful. I have now code that compiles, but I'd like to know what was wrong with the first version.
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    Location:
    Sailing beyond the sunset
    #2
    What does this do?
    Code:
    trans.subtype = ( [self goingBackwards] ? kCATransitionFromLeft : kCATransitionFromRight );
    

    Kinda curious why goingBackwards isn't declared as a read-only property, synthesized to use goingBackwardsFlag as the ivar.
     
  3. idelovski, Nov 13, 2011
    Last edited: Nov 13, 2011

    idelovski thread starter macrumors regular

    Joined:
    Sep 11, 2008
    #3
    >What does this do?

    Nothing. The absurdity of the problem is not that my flag variable is read only or something like that. I can even do this:

    Code:
    - (BOOL)goingBackwards_1
    {
       return (YES);
    }
    ...
    
    trans.subtype = [self goingBackwards_1] ? kCATransitionFromLeft : kCATransitionFromRight;
    ... and it still produced the same error.

    On the other hand, this is all fine and cool:

    Code:
    NSString  *tmpStr = [self goingBackwards] ? kCATransitionFromLeft : kCATransitionFromRight;
    Crazy!


    EDIT:

    Seem to be something with GCC 4.2 in the Xcode 3.2.6. If I move the project to another Mac with Xcode 4 and sdk 5, the problem disappears.
     

Share This Page