• 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: Design Question: Where to observe using KVO?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Design Question: Where to observe using KVO?


  • Subject: Re: Design Question: Where to observe using KVO?
  • From: Patrick Mau <email@hidden>
  • Date: Fri, 11 Jul 2008 09:45:34 +0200

Ken Thomases wrote:

> How about a dictionary whose keys are NSValues representing the
> objects?  For each object, the value from the dictionary would be an
> NSMutableArray whose elements are the key paths being observed on that
> object.
>
>     // ...
>     NSValue* objectKey = [NSValue valueWithNonretainedObject:object];
>     NSMutableArray* keyPaths = [observers objectForKey:objectKey];
>     if (!keyPaths)
>     {
>         keyPaths = [NSMutableArray array];
>         [observers setObject:keyPaths forKey:objectKey];
>     }
>     [keyPaths addObject:keyPath];

Hi Ken

Do you think that observing lots of objects with lots
of keypaths is a good idea anyway?

Maybe I'm considering my first approch again, using only key-value
coding inside the view and move the observing somewhere else ...

What I like about your idea is the use of

 [NSValue valueWithNonretainedObject:object];

I didn't know that. I'm quite new to coocoa, but not to programming.

Since the number of keypaths for each object is constant, I might
decide using a custom bitmap object as the value part in the
dictionary. That bitmap would indicate which keypath is being observed.

Thanks a lot.
Patrick


_______________________________________________

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: Design Question: Where to observe using KVO?
      • From: Ken Thomases <email@hidden>
References: 
 >Design Question: Where to observe using KVO? (From: Patrick Mau <email@hidden>)
 >Re: Design Question: Where to observe using KVO? (From: "I. Savant" <email@hidden>)
 >Re: Design Question: Where to observe using KVO? (From: "I. Savant" <email@hidden>)
 >Re: Design Question: Where to observe using KVO? (From: Patrick Mau <email@hidden>)
 >Re: Design Question: Where to observe using KVO? (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Cocoa : Drag/ drop from a table view onto a NSTextfield
  • Next by Date: Re: Trigonometric Problem, Particularly tan() Function
  • Previous by thread: Re: Design Question: Where to observe using KVO?
  • Next by thread: Re: Design Question: Where to observe using KVO?
  • Index(es):
    • Date
    • Thread