I have an app which is based on storyboard based with UINavigationController
.
I have three views A, B, C. I am starting camera in View A when user hits a camera button , after successfully clicking image and getting that image I am calling segue to go to B which is a PUSH segue. In view B I am showing image with an option to process image. When user selects to process it goes to view C with a PUSH segue. Now what i want is after processing the image should be sent back to view B where I will show processed image.
Problem is when I pass the image back from C to B using a pointer to B (delegate
) app crashes.
Code is as below
In view B to pass image to view C:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure your segue name in storyboard is the same as this line
if ([[segue identifier] isEqualToString:@"Segue1"])
{
// Get reference to the destination view controller
CViewController *vc = [segue destinationViewController];
// Pass any objects to the view controller here, like...
vc.imageChosen = imageChosen;
vc.delegate = self;
}
}
delegate
is declared in CViewController
as follows:
@property (nonatomic,retain) id delegate;
In view controller C to return image back, I'm doing following
-(IBAction)actionBack
{
BViewController *vc = (BViewController *)delegate;
vc.imageChosen = imageCropped;
[self.navigationController popViewControllerAnimated:TRUE];
}
actionBack
is a selector attached to back button on view C
App crashes with EXC_BAD_ACCESS
on a line in BViewController.h
which is as follows
@property (nonatomic,retain) UIImage *imageChosen;
I have checked imageCropped
has valid data which i tried saving to gallery as well imageCropped
is a property in CViewController
with following declaration
@property (nonatomic,retain) UIImage *imageCropped;
I'm not understanding why this is crashing and assistance would be appreciated.