How to check whether a NSPoint lays inside a NSRect

Luuk picture Luuk · Apr 6, 2009 · Viewed 9k times · Source

I've created a mutable array containing NSRect values. I want to check whether the NSPoint I created is within this rectangle. What is the best way to do this in cocoa.

Answer

DisplacedAussie picture DisplacedAussie · Apr 6, 2009

From the Foundation Functions Reference:

BOOL NSPointInRect (
   NSPoint aPoint,
   NSRect aRect
);

"Returns a Boolean value that indicates whether a given point is in a given rectangle."