• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Question about model observers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about model observers


  • Subject: Re: Question about model observers
  • From: Keary Suska <email@hidden>
  • Date: Tue, 11 May 2010 09:17:43 -0600

On May 11, 2010, at 8:53 AM, Eric Giguere wrote:

> Also my though, this is a job for custom accessors.
>
> I also guess that your answer concerning the collections don't include the cases where you do it outside the model but in the controller layer. This has proven to be working in other parts of my app:
> 	[personsController addObserver: self
> 			   forKeyPath: @"arrangedObjects.count"
> 			   options: NSKeyValueObservingOptionNew
> 			   context: nil];

Nope--no exceptions. It just so happens that NSArrayController emits KVO notifications for arrangedObjects whenever its content array changes. The point here is that the controller is actually telling you that the property "arrangedObjects" has changed and *not* that any collection represented by "arrangedObjects" has changed. In fact, if the property type was less specific (such as "id"), it could possibly no longer represent a collection object at all!

There have been some lengthy discussions about this. An object may choose to emit KVO notifications for its collection properties (but this behavior should never be expected unless it is specifically documented), but no collection will ever emit a KVO notification that its contents have changed (unless, of course, you subclass and add this behavior).

> But that's in another situation where this time, the job really is for the controller layer to take care of it since it involves

It's not MVC--probably more of a mediator pattern--but I can't see that it would be necessarily bad to use the controller in this case.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

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

  • Follow-Ups:
    • Re: Question about model observers
      • From: Ken Thomases <email@hidden>
References: 
 >Question about model observers (From: Eric Giguere <email@hidden>)
 >Re: Question about model observers (From: Keary Suska <email@hidden>)
 >Re: Question about model observers (From: Eric Giguere <email@hidden>)

  • Prev by Date: Re: Question about model observers
  • Next by Date: Local Storage (SQL Database) not working in my app built with XCode
  • Previous by thread: Re: Question about model observers
  • Next by thread: Re: Question about model observers
  • Index(es):
    • Date
    • Thread