开发者

Use of NSSet to hold a list of delegates in Objective C

I am writing a component (e.g. VeryLongJobExecuter) in Objective C.

I want this VeryLongJobExecuter to be able to notify other objects (one to many) when its job is finished, and execute a common method, e.g. (jobExecuted).

I a开发者_开发技巧m thinking to store the reference of these delegates in either NSArray/NSSet, and iterate the delegates and call the method.

Or should I use Notification instead?


The reason that we have notifications is so that you don't have to keep a reference to every other object that might care about an event. Don't re-invent the wheel.


Notification was done for that purpose so I would use that instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜