1

我想修复线程 1 EXC_BAD_ACCESS(code=2,address=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
4

1 回答 1

1

尝试更改代码:

word_id = [[NSString alloc]init];  

word_id = [NSString stringWithString:@""];
于 2012-10-19T09:37:15.347 回答