Calling getter on const object
Calling getter on const object
- Subject: Calling getter on const object
- From: Jonny Taylor <email@hidden>
- Date: Mon, 8 Nov 2010 12:59:18 +0000
I have encountered what I presume is a common newcomer's problem, but I haven't had any luck with google (maybe I'm using the wrong search terms?). Suppose I have a const id, e.g. "const id<FrameProtocol> frame". If I attempt to call a getter for the object I get the following compiler error:
request for member 'frameNumber' in 'frame', which is of non-class type 'objc_object* const'
Is there any way of declaring the getter (which in this case is just the auto-synthesized one...) as const (or otherwise express the fact that it can be safely called on a const object)? I assume that the auto-synthesized one *is* const - certainly there's no reason for it not to be that I can think of.
The reason I am in fact encountering this is when I attempt to access properties from within a block, where the instance is treated as 'const' by default.
There are of course ways I can work around all this, I just feel that I am missing the 'right' way of doing this. Any comments?
Thanks
Jonny
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden