views:

589

answers:

4

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.

A: 

NSPointInRect?

gargantaun
+5  A: 

From the Foundation Functions Reference

NSPointInRect

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

BOOL NSPointInRect ( NSPoint aPoint, NSRect aRect );

DisplacedAussie
+1  A: 

A valid question because not everyone realises that there are a great many helper functions provided in the Foundation.h file which save you having to re-invent the wheel all over the place.

Have a quick read through the reference to see all the different places it can help. I found it very useful when starting out.

Abizern
+1  A: 

I started this thread http://stackoverflow.com/questions/508894/what-cocoa-core-foundation-helper-functions-do-you-wish-you-knew-about-2-years-ag You may find something else you didn't know about.

Mark Thalman