i have two view controllers, AbcViewController and XyzViewController. Both controllers behave similarly. Each has a "add" button which opens up a AddNewAbcViewController and AddNewXyzViewController respectively.
On AddNewAbcViewController, when the button "submit" is taped, it does it necessary stuff and close, bringing it back to AbcViewController. I am using delegate here where AbcViewController does the closing of AddNewAbcViewController. This works.
Now I want to do the same for XyzViewController and AddNewXyzViewController, but it is not working. When the btnSubmit is called in AddNewXyzViewController, it didn't enter into XyzViewController dimiss method. I have scanned through my codes many times but don't find anything extra not added. I even gave a different dismiss method name in XyzViewController and AddNewXyzViewController but that didn't work either. What did I miss?
here are my snippets for AbcViewController and AddAbcViewController. The codes for Xyz are identical:
class AddNewAbcViewController.h is
#import <Foundation/Foundation.h>
// protocol
@protocol AddNewAbcProtocol <NSObject>
-(void)dismiss;
@end
@interface AddNewAbcViewController : UIViewController<UITextViewDelegate>
@property(nonatomic, weak)id<AddNewAbcProtocol> delegate;
@end
class AddNewAbcViewController.m is
@interface AddNewAbcViewController() <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
...
@end
@implementation AddNewAbcViewController
...
- (IBAction)btnSubmit:(id)sender
{
[self.delegate dismiss];
}
@end
class AbcViewController.h is
#import <Foundation/Foundation.h>
#import "AddNewAbcViewController.h"
@interface AbcViewController : UIViewController<AddNewAbcProtocol, UISplitViewControllerDelegate>
...
@end
class AbcViewController.m is
@implementation AbcViewController
-(void)dismiss
{
NSLog(@"delegated to dismiss()");
[self dismissViewControllerAnimated:YES completion:nil];
}
@end