博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

From the documentation of -[NSArray indexOfObjectIdenticalTo:]

Posted on 2013-02-01 15:05  酸梅拯救地球  阅读(301)  评论(0)    收藏  举报

From the documentation of -[NSArray indexOfObjectIdenticalTo:]:

Return Value

The lowest index whose corresponding array value is identical to anObject. If none of the objects in the array is identical to anObject, returns NSNotFound.

and NSNotFound is defined as:

enum{NSNotFound=NSIntegerMax};

and 2147483647 = 0x7fffffff is the maximum integer in iOS.

//buttonId is NSArray
- (void)eventTouchObserved:(id)sender
{
    UIButton *touchedButton = [buttonId objectAtIndex:[buttonId indexOfObjectIdenticalTo:sender]];
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:touchedButton cache:NO];
    [UIView commitAnimations];
    [touchedButton setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@.png",[touchedButton currentTitle]]] forState:UIControlStateNormal];
}