I have 2 view controllers connected with a segue (I will call these view controller 1 and view controller 2), where I pass an entity called Lead from view controller 1 to view controller 2 using the prepare. I use this same mechanism to pass this same lead to other view controllers and I also use view controller 2 from other view controllers and works fine.
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
UIViewController *destinationVC = segue.destinationViewController;
if([destinationVC isKindOfClass:[UINavigationController class]])
destinationVC = ((UINavigationController *)destinationVC).topViewController;
if([destinationVC respondsToSelector:@selector(setLead:)]) {
[destinationVC performSelectorOnMainThread:@selector(setLead:) withObject:self.lead waitUntilDone:YES];
}
However in this particular case, when from view controller 2, I try to access this lead property from anywhere (in this case first accessed in the viewDidLoad, I get EXC_BAD_ACCESS code=1 with (lldb) in the console and no other help whatsoever. Again, I use this same code in this view controller 2 from other view controller which also pass the Lead entity here and works fine.
if([self.lead.category isEqualToNumber:@(Buyer)])
outputImage = [BackgroundGradient blueGradientWithRect:self.tableView.bounds];
Next thing I did was to create a new property... just copy and paste of the property declaration from lead to lead2 and pass the data to that one instead... that was it worked and I am getting to view controller 2 without a crash and am able to see and change the data no problem, however when I hit back to go back to view controller 1, I am getting another EXC_BAD_ACCESS on the @implementation line of view controller 2 with .ccx_destruct message in the trace and the app freezes.
I have no idea what's going on and it's driving me insane now. I've tried using the NSZombieEnabled and instruments however no luck. Any help would be greatly appreciated! I have been fighting with this issue for two days now. I am on iOS7 debugging on an iPhone 5s running with Xcode 5 on Mavericks. I am using Storyboards with ARC for a project which should also deploy to iOS6.
Thanks!