Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MacDonaldsd

macrumors 65816
Original poster
Sep 8, 2005
1,005
0
London , UK
Hi,

I am trying to use NSPredicate to query a CoreData to-many relationship, but it errors, as it is calling it on the NSMutableSet, and not the objects themselves.

My "item" has a to-many relationship called "tags" and each tag has a name property which is an NSString.

Im trying to create an NSPredicate that sees if ANY of the Tag's name property, matches a given string.

I have tried using "ANY tags.name MATCHES[c] %@" but I get the error

[<_NSFaultingMutableSet 0x1005708f0> addObserver:forKeyPath:eek:ptions:context:] is not supported. Key path: name


Any ideas are greatly appreciated, as Im a bit stuck.

Cheers
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
Probably the %@ needs to be in quotations. i.e. the predicate should be of the form: "ANY tags.name MATCHES[c] \"%@\""
 

MacDonaldsd

macrumors 65816
Original poster
Sep 8, 2005
1,005
0
London , UK
Hi Eraserhead,

NSPredicate does the quotes for me :D

It seems if I do it in code using an NSFetchRequest it works, but if I set the filter predicate on a NSArrayController it fails.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.