Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
870 views
in Technique[技术] by (71.8m points)

objective c - Assigning to 'readonly' return result not allowed, but property is declared "readwrite"

I have a class with readwrite int properties:

@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 to 'readonly' return result of an Objective-C message not allowed

What is the problem?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

wrong syntax!

call

[self setFigure1:1];

or

self.Figure1 = 1;

(it's the same, thanks to @synthesize [i hope you did add a synthesize]!)

And: BTW: you might use lowercase-camelcase for your instance variable. It's kind of global-common. :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...