NSPredicateを使用してオブジェクトの配列を検索しようとしています。オブジェクトには、フィルタリングするNSStringプロパティがいくつかあります。NSPredicateの問題
私はフィルタリング行うには、次のコードを持っている:
NSString *predicateString = [NSString stringWithFormat:@"name like[c] %@",self.textFieldOutlet.text];
NSPredicate *searchPredicate = [NSPredicate predicateWithFormat:predicateString];
NSArray *results = [[MySingleton sharedMySingleton].cardArray filteredArrayUsingPredicate:searchPredicate];
をしかし、私は次のエラーを取得する:
WebKit discarded an uncaught exception in the webView:shouldInsertText:replacingDOMRange:givenAction: delegate: <NSUnknownKeyException> [<CardObject 0x14a530> valueForUndefinedKey:]: this class is not key value coding-compliant for the key test.
私は%@
周りの単一引用符を入れた場合、それは動作しますが、のみ入力した場合テキストは名前キーに保持されている値とまったく同じであり、値が「好き」ではない場合したがって非常に有用ではない。私は述語の文字列に何か間違っている必要があります、誰も助言できますか?
ありがとうございます!
あなたはpredicateStringに格納する値を投稿しますか? –
エラーは無関係です。一重引用符を挿入したときにのみアプリが動作することを再確認できますか? –
遅延の人々については残念です。 @iApple predicateString = [c] testのような名前です。 – bennythemink