Core Data Predicates with Subclassed NSManagedObjects
Posted
by coneybeare
on Stack Overflow
See other posts from Stack Overflow
or by coneybeare
Published on 2010-05-07T00:03:16Z
Indexed on
2010/05/07
0:08 UTC
Read the original article
Hit count: 221
I have an AUDIO class. This audio has a SOUND_A subclass and a SOUND_B subclass. This is all done correctly and is working fine.
I have another model, lets call it PLAYLIST_JOIN, and this can contain (in the real world) SOUND_A's and SOUND_B's, so we give it a relationship of AUDIO and PLAYLIST.
This all works in the app.
The problem I am having now is querying the PLAYLIST_JOIN table with an NSPredicate. What I want to do is find an exact PLAYLIST_JOIN item by giving it 2 keys in the predicate
sound_a._sound_a_id = %@ && playlist.playlist_id = %@
and
sound_b.sound_b_id = %@ && playlist.playlist_id = %@
The main problem is that because the table does not store sound_a
and sound_b
, but stored audio
, I cannot use this syntax. I do not have the option of reorganizing the sound_a and sound_b to use the same _id attribute name, so how do I do this?
Can I pass a method to the predicate? something like this:
[audio getID] = %@ && playlist_id = %@
© Stack Overflow or respective owner