You initialize this incorrectly. Try the following:
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = CGRectMake(100, 200, 50, 70); [self.view addSubview:button]; if (buttonArray == nil) { buttonArray = [[NSMutableArray alloc] init]; } [buttonArray addObject:button];
source share