Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 19, 2009, 04:12 AM   #1
MacDonaldsd
macrumors 65816
 
MacDonaldsd's Avatar
 
Join Date: Sep 2005
Location: London , UK
Using NSPredicate to query a Core Data to-many relationship

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:forKeyPathptions:context:] is not supported. Key path: name


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

Cheers
MacDonaldsd is offline   0 Reply With Quote
Old Dec 19, 2009, 05:13 AM   #2
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: UK
Probably the %@ needs to be in quotations. i.e. the predicate should be of the form: "ANY tags.name MATCHES[c] \"%@\""
Eraserhead is offline   0 Reply With Quote
Old Dec 19, 2009, 05:19 AM   #3
MacDonaldsd
Thread Starter
macrumors 65816
 
MacDonaldsd's Avatar
 
Join Date: Sep 2005
Location: London , UK
Hi Eraserhead,

NSPredicate does the quotes for me

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.
MacDonaldsd is offline   0 Reply With Quote
Old Dec 19, 2009, 07:44 AM   #4
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: UK
<shrug> I've always used quotes like that in my code.
Eraserhead is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Core data relationship cpuin Mac Programming 0 Oct 14, 2013 03:55 PM
Core Data One to Many Relationship zyzz12 iOS 6 0 Jul 30, 2013 12:14 PM
Core data relationship fault : null key ramy1989 Mac Programming 0 Nov 7, 2012 03:19 PM
How to select NSNumber data with NSPredicate?? mikezang iPhone/iPad Programming 0 Oct 17, 2012 09:39 AM
How to create a core data with more than 1 table with relationship? kimbebot iPhone/iPad Programming 3 Jul 31, 2012 02:42 AM

Forum Jump

All times are GMT -5. The time now is 07:26 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC