I'm using blocks to pass data from a view controller, VC3, which appears within a modal view that is pushed by VC1. The modal displayed is VC2, and it shows VC3 before being dismissed.
I am getting a EXC_BAD_ACCESS error when using the blocks.
Below is the code.
VC1.m
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
self.VC2 = [storyboard instantiateViewControllerWithIdentifier:@"VC2"];
VC3 *VC3 = [storyboard instantiateViewControllerWithIdentifier:@"VC3"];
VC3.onDismiss = [^(VC3 *sender, NSMutableArray *details)
{
//set stuff here
} copy];
[self presentViewController:VC2 animated:YES completion:nil];
VC3.h
@property (nonatomic, strong) void (^onDismiss)(VC3 *sender, NSMutableArray* details);
VC3.m
[self dismissViewControllerAnimated:YES completion:^{
NSMutableArray *details = [NSMutableArray array];
[details addObject:x];
[details addObject:y];
[details addObject:z];
self.onDismiss(self, details);
}];
I've tried and failed to get this working a few times. If someone could help me with this, I would be really grateful.