// Add the button to the NSMutableArray.
...
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[[self hBtns] addObject:btn];
...
// In another method, try to see if it exists.
- (void)didPushBtn:(id)sender
{
UIButton *btn = (UIButton *)sender;
if ([[self hBtns] containsObject:btn]) // Is false every time.
...
}
Почему он не обнаруживает, что UIButton находится в массиве?
EDIT
Оказывается, он даже не обнаружит его сразу после добавления:
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[[self hBtns] addObject:btn];
if ([[self hBtns] containsObject:btn]) // Returns false.