Re: NSPredicateEditorRowTemplate
Re: NSPredicateEditorRowTemplate
- Subject: Re: NSPredicateEditorRowTemplate
- From: Chris <email@hidden>
- Date: Tue, 24 Jun 2008 23:46:30 +1000
Hi!
This is very interesting information. Wish it was in the doco!
I have a custom view which wasn't responding to setObjectValue /
objectValue.
When I add those methods I find that on startup it does indeed copy
the values from object "C" to object "B". This means that when I
retrieve the values later on, instead of returning blank like before,
it now returns the old value instead of blank. However I need the new
value! If it were to copy the values across AFTER the user made
changes or prior to me calling objectValue, then it would work. I
thought maybe [rulePredicateEditor reloadPredicate] sounded like it
might do it perhaps, but that doesn't help either. Once the user hits
ok, we are still left with bogus values from object "B", albeit now
old values instead of nil values.
On 24/06/2008, at 11:02 PM, Jim Turner wrote:
On Tue, Jun 24, 2008 at 2:02 AM, Chris <email@hidden> wrote:
When the user clicks ok, then I call objectValue on the
NSPredicateEditor
and it calls predicateWithSubpredicates not on object "C", but on
object
"B", which is always going to be blank, because it is in fact
object "C"
which is the one displayed. Thus I can never retrieve values from
the row.
This phantom and unexplained object "B" that is created during NIB
loading
suddenly seems to be the one it cares about.
I'm not sure where to go next. Has anyone got any advice?
Hi Chris,
I saw this very same behavior and was fortunate enough to get the
following explanation from Peter Ammon:
"A single row may be composed of views from multiple templates. When
it's time to construct a predicate for that row, we pick one template,
and if its views are not actually in the row, we call objectValue on
the view in the row, and then setObjectValue: on the corresponding
view in your template.
Due to a bug, this happens more often than it should :(
What this means for your NSTextField subclass is that it should do the
right thing for objectValue and setObjectValue:. The object value of
your view should encapsulate all the state your template needs to
compute that portion of the predicate."
The short answer, for me at least, was to make sure my custom
NSTextField in my template handled objectValue/setObjectValue:
properly. That way, when predicateWithSubpredicates: is called, the
internals of the editor can pass around the values needed to properly
compute the predicate.
--
Jim
http://nukethemfromorbit.com
_______________________________________________
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