I know there are a few questions on stack alrdy 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
}
@protocol mapDelegate <NSObject>
And for the OP, @protocol is not terminated with a semi-colon - CodaFi 2012-04-05 21:12
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.
@class ExternalClass;
? (I still feel this is basically a "make the delegate be a real object" problem. - Phillip Mills 2012-04-05 21:17
delegate = self;
in which case he is assigning the delegate to the unused ivar, or isn't setting it at all.. - lnafziger 2012-04-05 21:19
viewDidLoad
[self setDelegate:_delegate];
, I just forgot to include that in the question - Solid I 2012-04-05 21:25
_delegate = _delegate;
which does you no good. - Phillip Mills 2012-04-05 21:28
[self setDelegate:(id <mapDelegate>)[[UIApplication sharedApplication] delegate]];
to set it to your appDelegate (which is where your function is) - lnafziger 2012-04-05 21:30
@protocol mapDelegate;
conform to NSObject? Also, where are you setting your app delegate as themapDelegate
- CodaFi 2012-04-05 20:47