• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to avoid warning with objc_msgSend
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to avoid warning with objc_msgSend


  • Subject: Re: How to avoid warning with objc_msgSend
  • From: Ryan Norton <email@hidden>
  • Date: Tue, 5 Oct 2004 01:46:20 -0700

Hi John,

It's pretty unusual to call objc_msgSend() yourself.  What are you trying to do?

Trying to call something that may not exist on the system :).

For example, in our case, getRectsBeingDrawn only exists on 10.3 - but we want our app to be able to work on 10.1 and up without any warnings (runtime or otherwise) -

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) :).

Or, if you just want to silence the warning, make sure you've imported a header that declares -getRectsBeingDrawn:count: before you get to that line, or just replace

@selector(getRectsBeingDrawn:count:)

with

NSSelectorFromString(@"getRectsBeingDrawn:count:")

Hmmm, that doesn't appear to work (the runtime warning is still there :\)...

One way I've figured out how to do it -
//getRectsBeingDrawn:count: is a optimization that is only available on
//Panther (10.3) and higher. Check to see if it supports it -
if ( [GetNSView() respondsToSelector:@selector(getRectsBeingDrawn:count:)] ) objc_msgSend(GetNSView(),@selector(getRectsBeingDrawn:count:),&rects,&co untRects);

In this case though it's a runtime check from a function that gets called quite a bit...

Thanks,
Ryan

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: How to avoid warning with objc_msgSend
      • From: Finlay Dobbie <email@hidden>
    • Re: How to avoid warning with objc_msgSend
      • From: Glenn Andreas <email@hidden>
    • Re: How to avoid warning with objc_msgSend
      • From: m <email@hidden>
References: 
 >Re: How to avoid warning with objc_msgSend (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: Re: Equivelent to drawRect: for drawing after sub views are drawn
  • Next by Date: Re: How to avoid warning with objc_msgSend
  • Previous by thread: Re: How to avoid warning with objc_msgSend
  • Next by thread: Re: How to avoid warning with objc_msgSend
  • Index(es):
    • Date
    • Thread