Re: Design Question: Pro & Cons of KVC/KVO
Re: Design Question: Pro & Cons of KVC/KVO
- Subject: Re: Design Question: Pro & Cons of KVC/KVO
- From: Phil <email@hidden>
- Date: Fri, 22 Aug 2008 16:22:52 +1200
On Fri, Aug 22, 2008 at 3:59 PM, Kyle Sluder
<email@hidden> wrote:
> @implementation ToolBar
> {
> -(id) init
> {
> [[[NSNotificationCenter] defaultCenter] addObserver:self
> selector:@selector(splitViewResized:) object:mySplitView];
> }
-(void)dealloc
{
[[NSNotificationCenter] defaultCenter] removeObserver:self];
[super dealloc];
}
@end
I've generally only used notifications for events that can't be
handled with KVO---ie. those that aren't associated with a property
change; and I've noticed that this is generally the trend in Cocoa
frameworks as well. Why use NSNotifications when there's already
perfectly good notification mechanism?
That said, notifications also give you a lot more flexibility about
when observers will be called, and coalescence of multiple
notifications.
Phil
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden