我有这个简单的 switch 语句:
switch ([sender tag]) {
case 0:
[NVAlertView showNVAlertViewFromView:self.view
title:@"STOCK NUMBER"
description:@"XXXXXXXXXXX"
cancelTitle:@"Cancel"
otherTitle:@"DONE"
dismissBlock:^(BOOL canceled, NSString *description) {
if (!canceled) {
[newItem setObject:description forKey:@"stocknum"];
}
}];
NSLog(@"YOP!");
break;
case kDescription:
[NVAlertView showNVAlertViewFromView:self.view
title:@"DESCRIPTION"
description:@"Enter a description here."
cancelTitle:@"Cancel"
otherTitle:@"DONE"
dismissBlock:^(BOOL canceled, NSString *description) {
if (!canceled) {
[newItem setObject:description forKey:@"description"];
}
}];
break;
case kBrandName:
[NVAlertView showNVAlertViewFromView:self.view
title:@"BRAND NAME"
description:@"Enter a brand name here."
cancelTitle:@"Cancel"
otherTitle:@"DONE"
dismissBlock:^(BOOL canceled, NSString *description) {
if (!canceled) {
[newItem setObject:description forKey:@"description"];
}
}];
break;
case kPrice:
[NVAlertView showNVAlertViewFromView:self.view
title:@"PRICE"
description:@"$199.99"
cancelTitle:@"Cancel"
otherTitle:@"DONE"
dismissBlock:^(BOOL canceled, NSString *description) {
if (!canceled) {
[newItem setObject:description forKey:@"description"];
}
}];
break;
default:
NSLog(@"default");
break;
}
每次 aa 值达到默认情况时,它会打印出“默认”并且由于 EXC BAD ACCESS 导致程序崩溃。这是什么原因造成的?谢谢!