I have two view controllers. I created a custom segue from the first viewcontroller to the second one and viceversa and linked both segues to the following class: (I downloaded the class from an internet tutorial)
#import "SlideLeftCustomSegue.h"
@implementation SlideLeftCustomSegue
- (void)perform{
UIViewController *srcViewController = (UIViewController *) self.sourceViewController;
UIViewController *destViewController = (UIViewController *) self.destinationViewController;
CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[srcViewController.view.window.layer addAnimation:transition forKey:nil];
[srcViewController presentViewController:destViewController animated:NO completion:nil];
}
@end
(I just changed the transition from "Right" lo "Left" depending on which viewcontroller I am) I call the segue from a swipe gesture.
It works as expected, but sometimes, randomly, when I swipe to call the segue, it crashes. This is the error that appears.
pru(745,0x1ae6d5c40) malloc: *** error for object 0x170014930: Invalid pointer dequeued from free list
*** set a breakpoint in malloc_error_break to debug
(lldb)
How can I fix this?