I have a UINavigationController
in which there is a MainViewController with UITableView
and a ToolBar button. Selecting a UITableViewCell
will push to SecondViewController
and tapping Toolbar button will push to ThirdViewController
, both with StoryBoard segue.
Both ViewControllers are pushed OK for the first time, but when UINavigationController
pushes the SecondViewController
first and pop back to MainViewController
, then pushing ThirdViewController
will cause the app to crash. So I thought something has to be wrong with ThirdViewController's
code, but the error message is:
SecondViewController respondsToSelector:]: message sent to deallocated instance 0x115621d0
The weird thing is why SecondViewController
is in the error message while I'm pushing the ThirdViewController
?
I put breakpoint and prepareForSegue
on MainViewController
is getting called without error, viewDidLoad
on ThirdViewController
is getting called after that without error, but when I click continue at the end of viewDidLoad
the app crashes.
Using Instruments with Zombies enabled shows this:
I'm pushing ThirdViewController
, why the code goes into SecontViewController
segue? I couldn't get any idea what is wrong with the code? I'm using ARC, so I didn't released anything by mistake.
Screenshot of SB:
Class definition of all three View Controllers
// MainViewController.h
@interface MainViewController : UITableViewController <UIAlertViewDelegate, UIActionSheetDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, MFMailComposeViewControllerDelegate, UIPageViewControllerDelegate, UIPageViewControllerDataSource, SecondViewControllerDelegate> {
BOOL _thumbnailTapped;
}
- (void)showQuickTour:(id)sender;
- (void)Purchased;
- (IBAction) pickThumbnailImage:(id)sender;
@property (strong, nonatomic) UIPageViewController *pageViewController;
@property (strong, nonatomic) NSArray *pageTitles;
@property (strong, nonatomic) NSArray *pageImages;
@property (strong, nonatomic) NSArray *pageImages_3_5;
@property (nonatomic, weak) IBOutlet UIBarButtonItem *editOptionsLabel;
@property (nonatomic, strong) NSCache* thumbnailCache;
@property (nonatomic, strong) NSCache* emailCountCache;
@property (nonatomic, weak) NSIndexPath* currentIndexPath;
@property (nonatomic, readwrite) BOOL deleting;
@property (nonatomic, weak) ABContact *returnedMailingList;
@property (nonatomic, strong) SoundEffect* deleteFX;
@end
//SecondViewController.h
@protocol SecondViewControllerDelegate <NSObject>
- (void)getBackCurrentMailingList:(id)controller didFinishEnteringItem:(ABContact *)currentMailingList;
@end
@protocol ModalViewDelegate
@optional
- (void) getBackGroup:(NSDictionary *) group;
- (void) getBackContacts:(NSArray *)c andEmails:(NSArray *)e;
- (void) getBackPastedContacts:(NSArray *)contacts;
- (void) getBackPullView:(BOOL)pullled;
@end
@interface SecondViewController : UITableViewController <ModalViewDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIActionSheetDelegate, UIAlertViewDelegate, MFMailComposeViewControllerDelegate>
{
ABContact *currentML;
BOOL _isViewPulled;
}
- (IBAction) pickImage:(id)sender;
- (IBAction) composeEmail:(id)sender;
- (IBAction) PasteGroup:(id)sender;
- (IBAction) dismissPopUp:(id)sender;
@property (nonatomic, weak) IBOutlet UIBarButtonItem *composeButton;
@property (nonatomic, strong) NSCache* thumbnailCache;
@property (nonatomic, strong) ABContact* currentML;
@property (nonatomic, strong) NSMutableDictionary* currentMailingList;
@property (nonatomic, strong) NSArray* pastedContatcs;
@property (nonatomic, strong) NSDictionary* groupDictionary;
@property (nonatomic, readwrite) ABRecordID currentRecordID;
@property (nonatomic, strong) UIView* fadingView;
@property (nonatomic, strong) UILabel* fadingLabel;
@property (nonatomic, strong) UIActivityIndicatorView* fadingActivityIndicator;
@property (nonatomic, weak) id <SecondViewControllerDelegate> delegate;
@property (nonatomic, strong) SoundEffect* deleteFX;
@end
//ThirdViewController.h
@interface SettingsViewController : UIViewController <SKPaymentTransactionObserver, SKProductsRequestDelegate>
{
}
@property (strong, nonatomic) SKProductsRequest *request;
@property (strong, nonatomic) SKProduct *product;
@property (strong, nonatomic) NSString *productID;
@property (weak, nonatomic) IBOutlet UILabel *versionLabel;
@property (weak, nonatomic) IBOutlet UILabel *productLabel;
@property (weak, nonatomic) IBOutlet UITextView *productDescription;
@property (weak, nonatomic) IBOutlet UIButton *purchaseButton;
@property (weak, nonatomic) IBOutlet UIButton *buyButton;
@property (weak, nonatomic) IBOutlet UISwitch *soundFXSwitch;
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *loadingIndicator;
- (IBAction)buyProduct:(id)sender;
- (IBAction)restorePurchase:(id)sender;
- (IBAction)switchSoundFX:(id)sender;
- (IBAction)showQuickTour:(id)sender;
-(void)getProductID:(UIViewController *)viewController;
@end