NSArrayController fetchPredicate behaving badly
-
I'm having some difficulty with an NSArrayController that fetches a
subset of all the entities in my NSManagedObjectContext, and I think
it might be something simple, but I haven't been able to put my finger
on it...
I have two entities, "Reels" and "Scenes". Reels have many Scenes;
reels have an "isHidden" attribute. The array controller I'm having
trouble with fetches scenes that are in reels that are not hidden,
thus it's fetch predicate (in IB, and I've done this programatically)
is "reel.isHidden == NO".
When I open a document, the ArrayController finds the correct scenes,
the ones in unhidden reels. If I hide one reel and show another (by
clicking checkboxes bound to the isHidden attribute on reels, the
array controller persists in showing the scenes for the hidden reel
(this is the problem). The array controller refuses to find the
scenes in the unhidden reel no matter how many times I order it to
fetch: or fetchWithRequest:
UNTIL I save the document, at which time the array controller realizes
what's been going on and fetches the correct scenes.
Is my predicate right? I can't help thinking there's something goofy
going on in my NSManagedObjectContext, something not being committed
or updated or something.
On a side note, does anyone know why I can't see the fetchPredicate
for an NSArrayController in the debugger? No such member seems to
exist.
Thanks
Jamie Hardt
The Sound Department
http://www.soundepartment.com/
http://www.imdb.com/name/nm0362504/ -
9/11/08 10:29 AM, also sprach <jamiehardt...>:> I have two entities, "Reels" and "Scenes". Reels have many Scenes;
> reels have an "isHidden" attribute. The array controller I'm having
> trouble with fetches scenes that are in reels that are not hidden,
> thus it's fetch predicate (in IB, and I've done this programatically)
> is "reel.isHidden == NO".
>
> When I open a document, the ArrayController finds the correct scenes,
> the ones in unhidden reels. If I hide one reel and show another (by
> clicking checkboxes bound to the isHidden attribute on reels, the
> array controller persists in showing the scenes for the hidden reel
> (this is the problem). The array controller refuses to find the
> scenes in the unhidden reel no matter how many times I order it to
> fetch: or fetchWithRequest:
> UNTIL I save the document, at which time the array controller realizes
> what's been going on and fetches the correct scenes.
IIRC, this is expected behavior. Quirky, perhaps. What you probably want is
to apply the predicate also as a filter predicate. OTOH this should cause
the behavior you want> Is my predicate right? I can't help thinking there's something goofy
> going on in my NSManagedObjectContext, something not being committed
> or updated or something.
No, I think it has to do with object caching, but don 't quote me on that
;-)> On a side note, does anyone know why I can't see the fetchPredicate
> for an NSArrayController in the debugger? No such member seems to
> exist.
Why not? NSArrayController responds to -fetchPredicate. Shouldn't be any
problem there. Just po [arraycontroller fetchPredicate].
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business" -
Yeah that worked. Quirky is the word.
On Sep 11, 2008, at 10:42 AM, Keary Suska wrote:> 9/11/08 10:29 AM, also sprach <jamiehardt...>:
>
>> I have two entities, "Reels" and "Scenes". Reels have many Scenes;
>> reels have an "isHidden" attribute. The array controller I'm having
>> trouble with fetches scenes that are in reels that are not hidden,
>> thus it's fetch predicate (in IB, and I've done this programatically)
>> is "reel.isHidden == NO".
>>
>> When I open a document, the ArrayController finds the correct scenes,
>> the ones in unhidden reels. If I hide one reel and show another (by
>> clicking checkboxes bound to the isHidden attribute on reels, the
>> array controller persists in showing the scenes for the hidden reel
>> (this is the problem). The array controller refuses to find the
>> scenes in the unhidden reel no matter how many times I order it to
>> fetch: or fetchWithRequest:
>> UNTIL I save the document, at which time the array controller
>> realizes
>> what's been going on and fetches the correct scenes.
>
> IIRC, this is expected behavior. Quirky, perhaps. What you probably
> want is
> to apply the predicate also as a filter predicate. OTOH this should
> cause
> the behavior you want
Jamie Hardt
The Sound Department
http://www.soundepartment.com/
http://www.imdb.com/name/nm0362504/


