Reputation: 812
Does anyone know what kind of overhead CGRectContainsRect and CGRectIntersectsRect have?
I am trying to track and test a user gesture and am finding I am probably going to have to use a combination of both but not sure of the impact.
Imagine a grid of 5 squares and you want to test if the user drew a line from square 1 to 2.
Easy, CGRectContainsRect lets me know if the did draw only in square 1 and 2.
If they drew in say squares 1, 2 and 3 the same test would return false as CGRectContainsRect would say NO.
OK no lets say you want to test for drawing in squares 1,2 and 3 and the user only draws in square 1 and 2, CGRectContainsRect will return YES because rightly so the users stroke is within squares 1,2 and 3........but not actually in square 3 so a false reading is obtained!
Upvotes: 0
Views: 136
Reputation: 6777
You could iterate thru each of the 5 squares, checking CGRectIntersectsRect on each. For a larger array of squares this may become highly inefficient, but off the top of my head thats the best way I can think of.
Upvotes: 1