• 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
KVO and lazy loading
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

KVO and lazy loading


  • Subject: KVO and lazy loading
  • From: Ashley Clark <email@hidden>
  • Date: Tue, 21 Oct 2008 02:23:55 -0500

I'm pretty sure I've got this worked out and it seems to be working, BUT I thought that before and when I turned on Auto Arrange Content on my NSArrayController's this bug popped up. So I wanted to make sure I'm doing this right.


I'm lazily initializing objects that are being read from a database, similar to CoreData faulting. In my RMDatabaseObject class I've implemented a willAccessValueForKey: method that reads in data from the database if necessary. This method is being called at the beginning of my willChangeValueForKey: and willChangeValueForKey:withSetMutation:usingObjects: methods.


Originally, for every property that was being set through the willAccessValue method I was calling the willChange/didChange methods and it seemed to work well. At least until I turned on auto-arrange content on some array controllers. After that I started getting exceptions stating that observer's were being removed more times than they had been added on seemingly random key paths.

I finally found a comment by mmalc and seconded by Ronzilla at http://theocacao.com/comment/4423 that seems to indicate that one should NEVER post change notifications when doing this sort of lazy-loading.

So, after all that, my question is this, is this correct? Or will I run up against something else later if I'm not issuing change notifications during my initial database row loading?


Ashley _______________________________________________

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: KVO and lazy loading
      • From: Ron Lue-Sang <email@hidden>
  • Prev by Date: Re: Custom CALayer Action as animation key?
  • Next by Date: - (id)initWithBundle:(NSBundle *)bundle
  • Previous by thread: Re: Core Data saving / Leopard / The temporary directory at ...
  • Next by thread: Re: KVO and lazy loading
  • Index(es):
    • Date
    • Thread