I’m new to Objective C, but have extensive C++ experience.
I have a member variable called bOn, which I have declared as a readonly property.
I then synthesize it.
However, the compiler won’t let me read it, saying “Instance Variable ‘bOn’ is declared protected”. I would understand this error if I had not synthesized.
Here are my snippets:
@interface Button : NSObject
{
. . .
BOOL bOn;
}
@property (nonatomic, readonly) BOOL bOn;
And where I use it:
-(void) updateForButtonLeft:(Button *)butLeft Right:(Button *)butRight
{
BOOL bLeft = butLeft->bOn;
. . .
So what else am I forgetting to do?
Thanks,
Dave.
butLeft->bOn;is direct instance variable access and under all but very rare circumstances, is a really bad idea.What you’re looking for is:
Or