私のアプリケーションでNSNotificationCenterにオブザーバーの問題があります。1つのクラスのNSNotificationCenterに1つの名前を持つ2人のオブザーバーを追加
私のAppDelegateクラスは、NewsServiceというサービスを呼び出すための2つのサービスクラスを持っています(& NewsService)。
この2つのサービスクラスは、1つのQueueloaderクラスを単独で使用します。
2人のオブザーバがappdelegateクラスのサービスロード操作をリッスンすると、エラーが返され、クラッシュします。
APP DELEGATE CLASS
ExhibitionLoaderService *exhibitionService = [[ExhibitionLoaderService alloc] init];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exhitibionServiceComplete :) name:**CserviceComplete** object:nil];
[exhibitionService load];
NewsLoaderService *newsService = [[NewsLoaderService alloc] init];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(newsServiceComplete :) name:**CserviceComplete** object:nil];
[newsService load];
ExhibitionLoaderService.m & NewsLoaderService私は
をGOT同じ方法-(void)load
{
Queueloader *que = [[Queueloader alloc] initWithPath:CExhibitionURLPath isVerbose:NO];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didQueComplete:) name:CdidQueueloaderComplete object:nil];
[que startOperation];
[que release];
}
ERRORを持っています
[[NSNotificationCenter defaultCenter] postNotificationName:**CdidQueueloaderComplete** object:results];
2サービスクラスにはCdidQueueloaderCompleteがあります...問題はオブザーバーについてですがどのようにですか?何?
PS。プログラム受信信号EXC_BAD_ACCESS。
ありがとうございました。
私は、この例では非常に簡単なラインコードを作成しました。それが実行されるとき、あなたは私の問題が何かを見るでしょう。あなたがそれをチェックしたいなら、これはリンクです。 www.mobilbuzz.com/stackoverflow/NotificationCenterExample.zip – selcuk