RKSearchEngine Class Reference
Inherits from | NSObject |
Declared in | RKSearchEngine.h RKSearchEngine.m |
Overview
An instance of RKSearchEngine provides a simple interface for searching arbitrary objects for matching text. Searching is performed by constructing a compound NSPredicate and evaluating a collection of candidate objects for matches. RKSearchEngine is only suitable for searching a relatively small collection of in-memory objects that are not backed by Core Data (see RKManagedObjectSearchEngine).
Tasks
Configuring Search Parameters
-
mode
The type of matching to perform. Can be either RKSearchModeAnd or RKSearchModeOr.
property -
tokenizeQuery
A Boolean value that determines if the search query should be split into subterms at whitespace boundaries.
property -
stripsWhitespace
A Boolean value that determines if whitespace is to be stripped off of the search terms before searching.
property -
caseSensitive
A Boolean value that determines if search terms should be matched case sensitively.
property -
+ searchEngine
Creates and returns a search engine object.
Performing a Search
-
– searchFor:inCollection:
Searches a collection of RKSearchable objects for the given text using the configuration of the receiver and returns an array of objects for which a match was found.
-
– searchFor:onProperties:inCollection:
Searches a set of properties in a collection of objects for the given text using the configuration of the receiver and returns an array of objects for which a match was found.
Properties
caseSensitive
A Boolean value that determines if search terms should be matched case sensitively.
@property (nonatomic, assign, getter=isCaseSensitive) BOOL caseSensitive
Discussion
Default: NO
Declared In
RKSearchEngine.h
mode
The type of matching to perform. Can be either RKSearchModeAnd or RKSearchModeOr.
@property (nonatomic, assign) RKSearchMode mode
Discussion
Default: RKSearchModeOr
Declared In
RKSearchEngine.h
stripsWhitespace
A Boolean value that determines if whitespace is to be stripped off of the search terms before searching.
@property (nonatomic, assign) BOOL stripsWhitespace
Discussion
This can prevent search misses when the terms have leading/trailing whitespace.
Default: YES
Declared In
RKSearchEngine.h
Instance Methods
searchFor:inCollection:
Searches a collection of RKSearchable objects for the given text using the configuration of the receiver and returns an array of objects for which a match was found.
- (NSArray *)searchFor:(NSString *)searchText inCollection:(NSArray *)collection
Return Value
A new array containing the objects in the given collection for which a match was found.
Exceptions
- NSInvalidArgumentException
Raised if any objects contained in the search collection do not conform to the RKSearchable protocol.
Declared In
RKSearchEngine.h
searchFor:onProperties:inCollection:
Searches a set of properties in a collection of objects for the given text using the configuration of the receiver and returns an array of objects for which a match was found.
- (NSArray *)searchFor:(NSString *)searchText onProperties:(NSArray *)properties inCollection:(NSArray *)collection
Return Value
A new array containing the objects in the given collection for which a match was found.
Exceptions
- NSInvalidArgumentException
Raised if any objects contained in the search collection do not conform to the RKSearchable protocol.
Declared In
RKSearchEngine.h