Skip navigation.
 
mlRe: How to avoid warning with objc_msgSend
FROM : Finlay Dobbie
DATE : Tue Oct 05 18:15:36 2004

On 5 Oct 2004, at 09:46, Ryan Norton wrote:

>> Anyhow, assuming that GetNSView() is a function returning a pointer
>> to an NSViewInstance, why don't you just send it normally?
>>
>> id aView = GetNSView();
>> NSRect *rects;
>> int rectCount;
>> [aView getRectsBeingDrawn:&rects count:&rectCount];

>
> Because this generates both a runtime and compiler warning on 10.2 and
> lower (using the id instead of a plain GetNSView generates an extra
> compiler warning also) :).


Then do this:

id aView = GetNSView();
NSRect *rects = NULL;
int rectCount = 0;
if ([aView respondsToSelctor:@selector(getRectsBeingDrawn:count:)]) {
   [aView getRectsBeingDrawn:&rects count:&rectCount];
}

That obviously won't cause a runtime warning on 10.2 and lower. It'll
cause a compile-time warning, removing that would be an exercise for
the reader (hint: define a protocol, but this is really bad practice as
those methods aren't really implemented and thus the warning is
perfectly valid).

  -- Finlay

Related mailsAuthorDate
mlHow to avoid warning with objc_msgSend Ryan Norton Oct 5, 02:11
mlRe: How to avoid warning with objc_msgSend Andrew Pinski Oct 5, 02:15
mlRe: How to avoid warning with objc_msgSend m Oct 5, 02:32
mlRe: How to avoid warning with objc_msgSend John C. Randolph Oct 5, 06:32
mlRe: How to avoid warning with objc_msgSend Ryan Norton Oct 5, 10:46
mlRe: How to avoid warning with objc_msgSend m Oct 5, 11:34
mlRe: How to avoid warning with objc_msgSend Glenn Andreas Oct 5, 16:01
mlRe: How to avoid warning with objc_msgSend Finlay Dobbie Oct 5, 18:15
mlRe: How to avoid warning with objc_msgSend David Elliott Oct 5, 20:28
mlRe: How to avoid warning with objc_msgSend Shawn Erickson Oct 5, 20:55