2012-08-08 2 views
0

저는 프로그래밍을 더 잘하기 위해 자체 NSNotificationCenter를 만들려고합니다. EXC_BAD_ACCESS를 실행 중입니다.내 자신의 NSNotificationCenter 만들기, 객체 저장 중?

내 방법 :

- (void)addObserver:(id)observer forKey:(NSString *)theKey withSelector:(SEL)block { 
    NSString *selector = NSStringFromSelector(block); 
    NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:observer, @"o",selector, "s", nil]; 
    [[observers objectForKey:theKey] addObject:dict]; 
} 

나는 NSDictionary *dict의 초기화에 오류가 발생하고, 그 이유를 이해하지 않습니다. 옵저버가 추가되는 것은 UIViewController이며이 방법은 viewDidLoad인데, 이는 applicationDidFinishLaunching으로 실행됩니다.

나는

어떤 도움 1 주시면 감사하겠습니다 = 오류 EXC_BAD_ACCESS 코드를 얻을 ,.

건배.

+1

''''전에 누락 된'@'만큼 쉽지는 않을까요? –

답변

2
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:observer, @"o",selector, "s", nil]; 

나에게 "s"가 빠진 것처럼 보입니다.

NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:observer, @"o",selector, @"s", nil]; 

귀하의 편의를 위해.

관련 문제