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
中運行。
我得到EXC_BAD_ACCESS錯誤代碼= 1
任何幫助,將不勝感激,。
乾杯。
它不可能像在''s「之前缺少'@'一樣簡單嗎? – 2012-08-08 22:11:06