我想修复线程1的错误EXC_BAD_ACCESS(代码= 2,地址= 0x30)当我点击按钮时出现此错误,按钮代码如下所示
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
DBHandler *db = [[DBHandler alloc]init];
word_id = [[NSString alloc]init];
NSLog(@"String %@",word_id);
[db addFavoriteWord:word_id];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)nextView:(id)sender {
}
@end
答案 0 :(得分:1)
尝试更改代码:
word_id = [[NSString alloc]init];
在
word_id = [NSString stringWithString:@""];