i'm having issues on my custom delegate, not sure why is not working.i wan to pass the delegate to the mainview so it will auto push to a detail view after adding a new record.
Not sure what i have missed out.i'm doing all the linkage with storyboard & iOS 5.
thanks for looking and appreciated all comments
addnote.h
#import <UIKit/UIKit.h>
#import "memoView.h"
@protocol addNoteDelegate;
@interface addNote : UIViewController
{
IBOutlet UITextField *memoNameTextField;
IBOutlet UITextField *memoCommentsTextField;
id <addNoteDelegate> delegate;
}
@property (nonatomic,assign) id <addNoteDelegate> delegate;
- (IBAction)done:(id)sender;
- (IBAction)cancel:(id)sender;
@end
@protocol addNoteDelegate <NSObject>
-(void)addNoteDidFinish:(addNote *)controller;
-(void)addNoteDidCancel:(addNote *)controller;
@end
addnote.m
-(IBAction)add:(id)sender
{
[[self delegate] addNoteDidFinish:self];
}
mainview.h
#import <UIKit/UIKit.h>
#import "addNote.h"
@interface mainView : UITableViewController<NSFetchedResultsControllerDelegate, addNoteDelegate>
{
}
@property (nonatomic, retain) NSArray *memoInfo;
@property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;
@property (nonatomic, retain) NSManagedObjectContext *ObjectContext;
-(IBAction)backToMain:(id)sender;
- (IBAction)addNote:(id)sender;
@end
mainView.m
-(IBAction)addNote:(id)sender
{
addNote *addingNote = [[addNote alloc] init];
addingNote.delegate = self;
[self performSegueWithIdentifier:@"addNote" sender:self];
}
- (void)addNoteDidFinish:(addNote *)controller{
//PUSH TO NEXT VIEW
[[self navigationController] dismissModalViewControllerAnimated:YES];
}