• 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
Binding chicken and egg problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Binding chicken and egg problem


  • Subject: Binding chicken and egg problem
  • From: Adrian Ruigrok <email@hidden>
  • Date: Thu, 29 Sep 2005 11:09:57 -0700

I have a view displaying objects. You can think of them like graphic objects: Circles and Squares.

I have a view inspecting the value of those objects. Radius for the circle, width for the square. This is a vast simplification but it illustrates the problem:

The inspector is different for a circle and a square. They have different values. Each of the objects has its own subview for inspecting its values and I swap that subview in and out depending no what object is selected. I have an arrayController watching what is selected. I have bound my custom controller's className to the kind of object being inspected. Each inspector view also has its own arrayController so I can tie up the fields in IB. I attach the inspectors array controller in code when the appropriate object needs to be inspected. When a circle is selected I remove whatever inspector is there and add the subView with the circle inspector and tie up its arrayController. In that subview the text field for the radius is bound to the selection.radius.

However I have a timing problem. If I put up the circle inspector when it is selected, then the bindings fail if the array controller has not updated still thinks it is looking at the square. I have even created my own arrayController and overridden willChange and didChange hoping it went something like:

willChange:objectClass
willChange:selection

do all the changes

didChange:objectClass
didChange:selection

But it seems to do them all in batches

willChange:objectClass
setObjectClass
didChange:objectClass

willChange:selection
setSelectedIndexes
didChange:selection
... or something like that.

So how do I resolve the dependancy. I need to be informed before any changes happen to the selectionIndexes so I an remove the bindings from the arrayController for the current inspector View. Then after the selection change has been completed I need to know so I can tie up the array Controller for the now selected object to the documents content and selection.

Hope this makes sense!

Thanks,
Adrian
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: NSError and user-cancel induced "errors"
  • Next by Date: Help modifying picture sharing example
  • Previous by thread: Re: NSError and user-cancel induced "errors"
  • Next by thread: Help modifying picture sharing example
  • Index(es):
    • Date
    • Thread