Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

idelovski

macrumors regular
Original poster
Sep 11, 2008
235
0
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.
 
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.
 
>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.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.