Tag Archives: address=0x10)

Block Wild Pointer crash: Thread 1:EXC_BAD_ACCESS(code=1,address=0x10)

In the past, the same method was used for block calls, but this time it was a crash. Mindless crash. Once called, it was a crash. The console did not print any crash information. Then it asked Du Niang about the wild pointer. To be honest, I read the code line by line. I searched for it for several hours. Later, I found that a new instance was created when the navigation controller was pushed, This causes the system to release the old instance

first said the functions I want to achieve: jump from the root controller to the first controller, then call the block in the first controller to change the background color of the controller and return to the first controller. p>

Code in the first controller:

//The second controller to jump to

@property (nonatomic, strong) BSOneController *oneVC;

– (void)viewDidLoad {

[super viewDidLoad];

BSOneController *oneVC = [[BSOneController alloc] init];

self.oneVC = oneVC;

oneVC.changeColor = ^(UIColor *color) {

self.view.backgroundColor = color;

[self.navigationController popViewControllerA nimated:YES ];

};

}

– (void)goOneVC:(UIButton *)btn{

//cause of crash: a new instance is created here, resulting in the release of self.onevc in advance, and then calling the instance’s block to cause crash

// BSOneController *one = [[BSOneController alloc] init];

// [self.navigationController pushViewC ontroller:one animated :YES];

[self.navigationController pushViewC ontroller:self.oneVC animated :YES];

}