Re: Trying to solve a to-many relationship?
Re: Trying to solve a to-many relationship?
- Subject: Re: Trying to solve a to-many relationship?
- From: Scott Stevenson <email@hidden>
- Date: Tue, 17 May 2005 21:55:04 -0700
On May 17, 2005, at 9:33 PM, Michael Carter wrote:
Hey all. Me again. I'm having continuing issues with syncing my
data model with my UI. I'd really appreciate some more input.
Heck, if you can help and are around the Cupertino area, free lunch
in a great cafeteria at a large computer company! :)
[...]
My first try was to set my app controller to observe the local
categories array for NSKeyValueObservingOptionOld changes. So, I
get notified when I delete a category from the panel okay. Then I
tried getting an enumerator for the RouteList array, then
enumerated through it's Jobs objects looking for properties that
matched the deleted category. It kind of worked, but feels clumsy
and never did get reflected once a match was found.
Hi Mike,
You have a few options.
One approach is to be to have each Job observe the master Categories
array via KVO. Inside the Job -observeKeyPath... implementation, you
can check the object(s) that were removed and see if the property
should be set to nil.
You could also post a regular NSNotification that all of the Job
objects listen for, though KVO observation might scale better with a
very large numbers of observers.
A third option is for the Categories to keep an array of nonretained
NSValue references to each of its Job objects, and notify them all
when it goes away. This is a bit more tricky and somewhat unorthodox.
The fourth is, of course, to use Core Data. :)
- Scott
--
http://treehouseideas.com/
http://theocacao.com/ [blog]
_______________________________________________
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