Assigning the result to "readonly" return is not allowed, but the property is declared "readwrite",

I have a class with readwrite intproperties:

@interface PlayScene : UIView

@property (readwrite, assign) int Figure1;
@property (readwrite, assign) int Figure2;
@property (readwrite, assign) int Figure3;

But when I try to change the value of the properties, an error occurs:

[self Figure1] = 1;

assigning a readonly result to an Objective-C message return is not allowed

What is the problem?

+5
source share
1 answer

wrong syntax!

call

[self setFigure1:1];

or

self.Figure1 = 1;

(this is the same, thanks @synthesize [hope you added synthesis]!)

And: BTW: you can use camel lowercase for your instance variable. This is something in common. :)

+14
source

All Articles