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

Icewind

macrumors regular
Original poster
May 23, 2006
166
13
Scotland
Hi Guys,

Ok, I'm a total newbie to Mac OSX coding but have about 20 years of Wintel Dev experience in various languages. I've just started creating some nice little Cocoa Apps and ventured into Core Data. Now I'm stuck. I have a data model with two related entities (Customer and Cheques 1:M). When I auto-generate the UI by option-dragging each entity to a window, the UI is created no problem and everything works. However, each entity has it's own Search box in the UI. So, searching for customer information in the Customer's search box will retrieve customer data correctly, and the same for the Cheques search box.

What I'm trying to achieve is to only have one search box on the UI, which will search for data in BOTH entities. Can this be done? I was playing around with the predicates for each search box, but couldn't see how I can target both entities in the same predicate.

Any help would be great.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Disclaimer: I don't use CoreData at the moment :D

So out of my lovely position of ignorance: I assume that the result of running the search predecate on an entity is some sort of collection (an NSArray?). So the simple solution is to run the predecate on each entity in turn and combine the output collections into one single collection.
 

Icewind

macrumors regular
Original poster
May 23, 2006
166
13
Scotland
Thanks for the suggestion Robbie, I will check this out when I get back home (I'm Scottish too...an Ayrshire Farm Boy, currently working in London Mon to Fri) :rolleyes:

I will check exactly what the Search box is doing when I get home. I never thought to check what it outputs the search results to (in terms of a data structure). I know that it updates the Table View (dynamically as you type) in order to narrow down the hits, exactly the same as Spotlight, iTunes etc. So it has to be updating that data structure, whatever it is.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.