Re: Implementing search field in core-data app

2010-01-08 Thread Matt Neuburg
On Thu, 7 Jan 2010 21:14:55 +0100, Martin Hewitson
martin.hewit...@aei.mpg.de said:
Dear list,

I have a fairly basic core-data model with a set of Category entities, each
category contains then a set of Item entities. What I want to do is implement a
search field which searches all items from all categories - something like the
searching is done in Mail.app.

I'm not really sure how to go about this. I've tried binding the predicate
bindings of an NSSearchField to the Item array controller, but this only
searches in the items of the currently selected category (since the array
controller is bound to categorycontroller.selection.items).

I also tried making another array controller which contains all items and then
set a filter predicate on this depending on the user having chosen a state: 'all
categories' or 'currently selected category'. Then I bound my table view to this
'all items array controller'. But this is not so nice since the relationship
between categories and items is not automatically handled.

Is there a 'correct' way to attack such a problem, or has someone else managed
to implement a search interface something like Mail.app?

What I would suggest is not using bindings with the search field. That way,
you can respond to the user's activities in the search field in any way you
like. Take a look, for example, at my Thucydides app - it comes with source
code, and uses Core Data, and is a very small simple app so you can see
readily what's going on. We simply respond to the old-fashioned
target-action signal from the search field by building a predicate and
applying that to the controller of the full array of entities.

Another complicating factor might your notion that a category entity
contains a set of Item entities. This, and your statement that the
relationship between categories and items is not automatically handled,
makes me wonder whether you've set up your Core Data model in the way that's
most appropriate for what you intend to do with this data. But the
Thucydides code won't help with that, since it has no categories: the Core
Data model is much simpler than what you describe.

m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Implementing search field in core-data app

2010-01-07 Thread Martin Hewitson
Dear list,

I have a fairly basic core-data model with a set of Category entities, each 
category contains then a set of Item entities. What I want to do is implement a 
search field which searches all items from all categories - something like the 
searching is done in Mail.app.

I'm not really sure how to go about this. I've tried binding the predicate 
bindings of an NSSearchField to the Item array controller, but this only 
searches in the items of the currently selected category (since the array 
controller is bound to categorycontroller.selection.items).

I also tried making another array controller which contains all items and then 
set a filter predicate on this depending on the user having chosen a state: 
'all categories' or 'currently selected category'. Then I bound my table view 
to this 'all items array controller'. But this is not so nice since the 
relationship between categories and items is not automatically handled.

Is there a 'correct' way to attack such a problem, or has someone else managed 
to implement a search interface something like Mail.app?

Best wishes,

Martin


Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Implementing search field in core-data app

2010-01-04 Thread Martin Hewitson
Dear list,

I have a fairly basic core-data model with a set of Category entities, each 
category contains then a set of Item entities. What I want to do is implement a 
search field which searches all items from all categories - something like the 
searching is done in Mail.app.

I'm not really sure how to go about this. I've tried binding the predicate 
bindings of an NSSearchField to the Item array controller, but this only 
searches in the items of the currently selected category (since the array 
controller is bound to categorycontroller.selection.items).

I also tried making another array controller which contains all items and then 
set a filter predicate on this depending on the user having chosen a state: 
'all categories' or 'currently selected category'. Then I bound my table view 
to this 'all items array controller'. But this is not so nice since the 
relationship between categories and items is not automatically handled.

Is there a 'correct' way to attack such a problem, or has someone else managed 
to implement a search interface something like Mail.app?

Best wishes,

Martin



Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com