objective-ciosobjective-c-protocol

Delegate is not calling method


So i have a question . Can someone Tell me the Problem with this line of code for calling(protocol) a Method

 [self.delegate poplogin];

poplogin is method name , its not working for some reason. its not calling the method poplogin

for reference :

@property(nonatomic,retain) id<loginAuthDelegate> delegate;

So let me Explain the Case

so lets say i have a Class abc.h

@protocol loginAuthDelegate <NSObject>
-(void)poplogin;
@end

After interface

@property(nonatomic,retain) id<loginAuthDelegate> delegate;

in .m i am just calling the Delegate and @synthesize it
[self.delegate poplogin];

not i have another files
let say def.h
i am importing the Class abc.h
@interface def : UIViewController<loginAuthDelegate>



def.m
-(void)poplogin
{
NSLog(@"Delegate doesn't respond to here");
vmpaSecureLogin *ivc = [[vmpaSecureLogin alloc] init];
ivc.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:ivc animated:YES];
}

Solution

  • This is probably because self.delegate is nil.

    You probably forgot to affect your object's delegate to some other object in which you implemented the delegate methods, like your ViewController or something.