CoreDataのクエリに検索条件の付与には、NSPredicateクラスを使えばできます。
例)大文字小文字を無視して、文字列で一致させる場合
```NSPredicate *predicate =[c] [NSPredicate predicateWithFormat:@"name = %@", @"HOGE"];
<pre><code><br />なお、ここで「=」の後に付けた「[c]」はcase-insensitiveを意味するオプションで、判定の際に文字通り大文字小文字の区別をなくすものです。また、他にも「[d]」があり、これはdiacritic-insensitiveを意味し、diacritic-markを無視します。
例)[cd]オプションを指定する
```NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name =[cd] %@", @"HÒĜÈ_1"]
ちなみに、NSPredicateで使用できるオペレータには以下のようなものがあります。
- =
- beginswith
- endswith
- like
- contains
- in
- matches
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K = %@", @"name", @"hoge"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K beginswith[c] %@", @"name", @"HO"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K endswith[c] %@", @"name", @"GE"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like[c] %@", @"name", @"H*"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K contains %@", @"name", @"ho"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K in %@", @"name", [NSArray arrayWithObjects:@"hoge", @"fuga", nil]];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K matches %@", @"name", @"^hoge_[0-10]$"];
- カラム名のプレースホルダーは%K