i am trying to modify my code little bit for the searching rect. my worked code is below
for(int i=0;i<[wordRects count];i++){
if(CGRectContainsPoint([[wordRects objectAtIndex:i] CGRectValue], tapedPoint)){
lineImage=[[UIImageView alloc] initWithFrame:[[wordRects objectAtIndex:i]CGRectValue]];
lineImage.backgroundColor=[[UIColor blueColor] colorWithAlphaComponent:0.3f];
[textSelectionView addSubview:lineImage];
break;
}
}
In the above code the wordRects array contains approximately 500 rects and tapedpoint is user tap point in the view. if the user taped point not in the array then in the worst case 500 iterations happen. *My Requirement * I want to reduce the iterations by using the binary search algo.Is there any use to implement that if yes can any one please modify my code according to binary search or give me some idea to implement this.Thanks in advance.