• 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
Custom View Binding, Arrays, and observeValueForKeyPath
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Custom View Binding, Arrays, and observeValueForKeyPath


  • Subject: Custom View Binding, Arrays, and observeValueForKeyPath
  • From: "Mazen M. Abdel-Rahman" <email@hidden>
  • Date: Wed, 19 May 2010 00:05:48 -0700

Hi all,

I have a general question about bindings - and I feel like there's something I'm not quite getting.

I have a custom view class with an array property.  I want to bind that array property to a model - which in my case is an array that is in a container/manager object.  The binding is done via  a custom view controller (in it's awakeFromNib). (calendar is the model object)

	[calendarView bind:@"events"
			  toObject:calendar
		   withKeyPath:@"events"
			   options:options];



Now whenever "events" in the object calendar is modified "events" in calendarView is modified as well.


In addition - observeValueForKeyPath... is getting called as well in the calendarView.

The problem is that if some items are removed from calendar's (the model) "events array" by the time observeValueForKeyPath in calendarView  gets called its "events" array has already been updated to reflect the model change.

In observeValueForKeyPath..  I can get the indexes of the removed array items - but those indexes are no longer valid as the "events" array in calendarView have already been removed.

What is the best way for calendarView to get the items of the array that are going to be removed before they are actually removed?

In the Change dictionary of ObserveValueForKeyPath I get a NSKeyValueChangeKindKey key and a NSKeyValueChangeIndexesKey - but no other keys that might contain the array before it was modified.

Thank you,
Mazen Abdel-Rahman
_______________________________________________

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: Custom View Binding, Arrays, and observeValueForKeyPath
      • From: Ken Thomases <email@hidden>
    • Re: Custom View Binding, Arrays, and observeValueForKeyPath
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Programmatic Binding
  • Next by Date: Re: Custom View Binding, Arrays, and observeValueForKeyPath
  • Previous by thread: custom formatters and preparedCellAtColumn:row:
  • Next by thread: Re: Custom View Binding, Arrays, and observeValueForKeyPath
  • Index(es):
    • Date
    • Thread