2015-01-28 4 views
-1

Objective-C 프로토콜에 문제가 있습니다.프로토콜이 선택자에 응답하지 않습니다.

I 정의한 프로토콜 :

@protocol PlayerProfileSectionProReviewDelegate <NSObject> 

- (void)didReceivedPlayerProfileSectionProReviewData; 

@end 

@interface PlayerProfileSectionProReviewModel : PlayerProfileSectionModel 

@property (weak) id <PlayerProfileSectionProReviewDelegate> playerProfileSectionProReviewDelegate; 

@end 

이 클래스 구현에서 I 호출 대리인 :

@interface PlayerProfileSectionProReviewViewController : PlayerProfileSectionViewController <UITableViewDelegate, UITableViewDataSource, PlayerProfileSectionProReviewDelegate> 

@end 

:

if ([self.playerProfileSectionProReviewDelegate respondsToSelector:@selector(didReceivedPlayerProfileSectionProReviewData)]) 
{ 
    [self.playerProfileSectionProReviewDelegate didReceivedPlayerProfileSectionProReviewData]; 
} 

보기 제어기 I가 didReceivedPlayerProfileSectionProReviewData 방법 PlayerProfileSectionProReviewDelegate을 첨가하고 재정의 한 및

#pragma mark <PlayerProfileSectionProReviewDelegate> 

- (void)didReceivedPlayerProfileSectionProReviewData 
{ 
    [self.playerProReviewTableView reloadData]; 
} 

왜 프로토콜이 선택기에 응답하지 않습니까?

당신의 PlayerProfileSectionProReviewViewController 클래스 구현에
+1

'_playerProfileSectionProReviewDelegate'는'nil'입니까? 또한'playerProfileSectionProReviewDelegate'를'weak' 속성으로 정의하고 싶을 것입니다. –

+0

네,'_playerProfileSectionProReviewDelegate'는'nil'입니다! 어떻게 처리할까요? –

+0

'playerProfileSectionProReviewDelegate' 속성을 정의했으나 이는 단지 속성 일뿐입니다. 그것은 변수의 이름 인 신발 상자입니다. _value_를 지정하지 않았습니다. 이 델리게이트 객체를 만들지 않는다면 거기에 아무 것도 없습니다. 신발 상자는 비어 있습니다 (nil). – matt

답변

0

어딘가에, 당신은 다음과 같이 적절한 PlayerProfileSectionProReviewModel 객체의 대리자를 설정해야합니다

myModel.playerProfileSectionProReviewDelegate = self; 

이렇게하면 myModel가 대리자 호출에 도달하면, 다음, 뷰 컨트롤러를 받게됩니다 .

if ([self.playerProfileSectionProReviewDelegate respondsToSelector:@selector(didReceivedPlayerProfileSectionProReviewData)]) 
{ 
    [self.playerProfileSectionProReviewDelegate didReceivedPlayerProfileSectionProReviewData]; 
} 

으로 :

그런데

, 당신은이 라인을 단순화 할 수있는 대리인이 nil 경우이 시점에서

[self.playerProfileSectionProReviewDelegate didReceivedPlayerProfileSectionProReviewData]; 

, 아니 메시지가 전송되지 않습니다 그리고 당신은받지 않습니다 모든 런타임 오류.

+0

정말 고마워요! 그것은 오랜 시간 동안 나를 데려 갔다 같은 어리석은 실수였다! –

관련 문제