아래에 소스가 있습니다.왜 SIGABRT 오류가 발생합니까?
- (void)Button:(UIButton *)button {
NSString *imageName = ((UIButton *)[self.view viewWithTag:button.tag]).titleLabel.text;
}
- (void)viewDidLoad {
NSMutableArray *_array = [[NSMutableArray alloc] init];
NSInteger iCount = [_array count];
for (i = 0; iCount > i; i++) {
UIButton *btn = [[UIButton alloc] init];
btn.titleLabel.text = [[_array objectAtIndex:i] objectForKey:@"FILE"];
btn.tag = i;
[btn addTarget:self action:@selector(Button:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
[btn release];
}
인덱스 메서드가 0 인 Button 메서드에 액세스하면 SIGABRT 오류가 발생합니다. 어떻게해야합니까?
이 오류는 사용자가 전달한 자체 객체가 실제로는 버튼이 아니라보기 컨트롤러이기 때문에 발생합니다. – rishi