• 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: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context?


  • Subject: Re: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context?
  • From: Motti Shneor <email@hidden>
  • Date: Mon, 10 Sep 2012 18:24:40 +0300

There isn't much UI going on here. The representedObject is a CoreData managed object, updated frequently by remote server notifications. I'm observing a to-many relation somewhere down the attribute-path of the representedObject, trying to filter only those new/updated items of interest.

Only very few of the changes actually cause UI updates in the viewController.

While observing those frequent changes, inspection of them in the model (which is constantly being updated), and filtering for the interesting ones is simply too CPU intensive. There are plenty of other parts of the program that need CPU. I'd like to avoid monitoring these changes when unnecessary.

Again --- I already solved this, in a non-elegant way (BOOL ivar that records the observation-state). It would be nicer to do this in a general manner, and without a member. Preferably, rely on the internal KVO mechanism.

On 10 בספט 2012, at 14:23, James Montgomerie wrote:

> On 10 Sep 2012, at 11:40, Motti Shneor <email@hidden> wrote:
>> My question is general. Supposedly I could NOT start observing once, and stop it once. Reasons:
>> 1. There are many instances of that NSViewController
>> 2. This observation is quite frequent in time (could reach 100 times a second)
>> 3. The code to filter-out unwanted value-changes is CPU intensive. (Accounting for 5 orthogonal conditions, upon which I should actually do something with the attribute change)
>
> Does your view controller need to be aware of all these changes? 100s of changes a second is faster than your display can operate so, if this code is just to keep your UI up to date, there's potentially a lot of redundant work going on.
>
> Is it possible that you could, instead of observing, do something simpler like poll for changes while whatever's causing them to happen is underway?  For example, could you use an NSTimer firing once every 30th or 15th of a second, calling a method that updates the UI?  This would avoid the overhead of processing all those 100s of changes per second in the view controller.
>
> Jamie.
>

Motti Shneor, Mac OS X Software Architect & Team Leader
Spectrum Reflections Ltd.




_______________________________________________

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


References: 
 >Re: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context? (From: Lee Ann Rucker <email@hidden>)
 >Re: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context? (From: Motti Shneor <email@hidden>)
 >Re: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context? (From: James Montgomerie <email@hidden>)

  • Prev by Date: Re: Converting NSImage with multiple image representations (HiDPI+LowDPI) into grayscale NSImage
  • Next by Date: Re: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context?
  • Previous by thread: Re: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context?
  • Next by thread: nstableview without nsscrollview
  • Index(es):
    • Date
    • Thread