4thSpace
4thSpace

Reputation: 44352

Do I need a protocol for notification?

I have classDownload that uses NSURLConnection. I'd like to keep all of the NSURLConnection events in classDownload. ClassA wants to use classDownload but also receive notifications such as connectionDidFinishLoading, which is called Finish in classDownload. How do I get the notifications from classDownload over to ClassA?

Upvotes: 0

Views: 184

Answers (1)

Marc W
Marc W

Reputation: 19251

Assuming classDownload is the delegate of the NSURLConnection, you could just use NSNotificationCenter to broadcast events when the delegate methods are called. Then, in classA, subscribe to the events in classDownload using addObserver:. Let me know if you need any clarification or code snippets.

Edit

To directly answer the question in your title, no, you do not need a protocol to subscribe to events published by an object using NSNotificationCenter.

Upvotes: 2

Related Questions