I am trying to utilize the NSNotificationCenter and for some reason the selector method is never called.
- (NewsItem *) loadNewsItemDetail:(NewsItem *)currentNewsItem
{
self.newsItem = currentNewsItem;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(DownloadNewsItem) name:@"connectionDidFinishLoadingComplete" object:nil];
return self.newsItem;
}
- (void) DownloadNewsItem:(NSNotification *) notification
{
NSString *urlString = [Configuration newsStreamAPIURL:plNewsAPIKey];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];
(void)[[NSURLConnection alloc] initWithRequest:request delegate:self];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
...
[[NSNotificationCenter defaultCenter] postNotificationName:@"connectionDidFinishLoadingComplete" object:nil];
}
Any reason why my DownloadNewsItem would never be called based on what I have provided?
Thanks!
You need a colon in your selector method, because it takes a parameter (an
NSNotificationin this case).