2012-10-03 4 views
0

질문이 있습니다. 누군가가 (프로토콜)이 방법대리인이 메서드를 호출하지 않습니다.

[self.delegate poplogin]; 

poplogin를 호출 나에게 코드의 문제를 말할 수있는 그 어떤 이유로 작동하지 않는, 방법 이름입니다. 참조하기위한 방법의 poplogin

를 호출하지의 :

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

그래서 나에게 사례를 설명하게

그래서 난 인터페이스 후

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

abc.h 클래스가 있다고 할 수 있습니다

@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]; 
} 
+1

위임자가 nil이 아닌 것은 확실합니까? – Kyle

답변

2

self.delegatenil이기 때문일 수 있습니다.

개체의 delegate에 ViewController 등의 대리자 메서드를 구현 한 다른 개체에 영향을주는 것을 잊었을 수 있습니다.

+0

질문이 업데이트되었습니다. – user1669730

+0

그래서 당신은 방금 내가 설명하는 것이 당신의 문제의 원인이라는 것을 확인했다 : 당신의 코드에 당신의 질문에 쓴 것처럼, 당신은 절대로 위임 속성을 값 (즉,'abcInstance.delegate = defInstance;')에 할당하지 않을 것이다. (self.delegate가'nil' 일 때'[self.delegate poplogin]'과 같이)'noil'에게 메시지를 보내면 아무런 일도하지 않을 것입니다 – AliSoftware

+0

제발 윤리 강령의 어디에 써야하는지 제안하십시오. 또는 당신이 저에게 더 좋은 예제를 주신다면 – user1669730

관련 문제