는이 코드를 건너 왔어요 :NSNotificationCenter 사용 :
는 관찰자가 먼저 제거하고 다시 추가 왜- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc removeObserver:self name:Hide object:nil];
[nc addObserver:self selector:@selector(MarkHide:) name:Hide object:nil];
}
?
나는이 질문을하기에 좋은 사람이이 코드를 작성한 사람이라고 생각한다. 나는 컨트롤러가 동일한 알림에 여러 번 등록되는 것을 방지해야한다고 생각합니다. 그것이 올바른 접근법이라면 - 물론 - opinon-based. – Eiko
이론 상으로는 ViewController가 Home을 누르고 다시 보여 주면 viewDidAppear :를 두 번 호출해야합니다. 옵저버를 제거하지 않으면 통지를 게시하면'MarkHide :'가 두 번 트리거됩니다. – Larme