I'm new at this too, so perhaps I am completely off here. My guess is that it isn't the const that is messing this up, but the non-class type. The problem I see is that "frame" is a pointer to an objc_object and objc_objects aren't the same as NSObjects (but, like I said, I'm new, so maybe they are interchangeable here). Does it work if you try declaring frame as a NSObject<FrameProtocol> instead of an id<FrameProtocol>?
Aaron On Nov 8, 2010, at 8:37 AM, Jonny Taylor wrote: > I'm afraid I'm not sure if I understand exactly what you're asking. I would > like to be able access the "frame number" property (which is in fact stored > as a variable within the class, and is fixed soon after instantiation) in > spite of the fact that I only have a 'const' pointer to the object at the > time I want to access it. Semantically I don't see why it should be unsafe to > attempt to find out the value of that property. > > Either way, hopefully the actual code helps to answer your question: > > -(void)analyzeFrameAsync:(id<FrameProtocol>)frame > { > int num = frame.frameNumber; // Temporary variable avoid > problems with calling method on 'frame' [const] from block > dispatch_async(analysisSerialQueue, > ^{ > [analyzer processFrame:frame]; > self.latestFrameNumberProcessed = num; // I can't call > frame.frameNumber from within the block (compiler error) > }); > } > > > > On 8 Nov 2010, at 16:29, David Duncan wrote: > >> It might be useful to know what you expect to get from the const reference >> in the first place? Primarily because I highly suspect that it is not >> necessary to ensure the semantics that you desire. >> >> On Nov 8, 2010, at 4:59 AM, Jonny Taylor wrote: >> >>> 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' >> >> -- >> David Duncan >> > > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/eeyore%40monsterworks.com > > This email sent to eey...@monsterworks.com > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com