Reputation: 690
I know there are a few questions on stack already regarding this, and I have been through them all.
When I debug, a line of code that calls a delegate method appears to be ignored. here's the line:
[_delegate insertDataLocation:dbLocation Time:dbTime Reminder:dbReminder];
I am assuming it's a matter of the delegate not being set properly, so here's how I've set it:
ViewController.h
@protocol mapDelegate;
@interface ViewController : UIViewController
@property (strong, nonatomic) id<mapDelegate> delegate;
ViewController.m
@synthesize delegate = _delegate;
- (void)viewDidLoad
{
[super viewDidLoad];
[self setDelegate:_delegate];
}
//Here's where I call the method, FYI
[_delegate insertDataLocation:dbLocation Time:dbTime Reminder:dbReminder];
AppDelegate.h
@protocol mapDelegate
-(void)insertDataLocation:(NSString*)l Time:(NSString*)t Reminder:(NSString*)r;
@end
@interface AppDelegate : UIResponder <UIApplicationDelegate, mapDelegate>
AppDelegate.m
-(void)insertDataLocation:(NSString*)l Time:(NSString*)t Reminder:(NSString*)r {
//Here's my method's code
}
Upvotes: 1
Views: 198
Reputation: 31016
1) Get rid of the id<mapDelegate> delegate;
declaration at the start of your .h file. You've tied your property to a variable called _delegate in your @synthesize statement, so the other one is misleading.
2) You say, "here's how i've set it," but I don't see anything that actually sets the delegate to be some object.
3) Using self.delegate
rather than _delegate
inside normal methods is usually a better idea.
Upvotes: 3