私はUIView
の配列を持っています。この配列に- (NSArray *)filteredArrayUsingPredicate:(NSPredicate *)predicate
を呼び出して、MyCustomView
オブジェクトを取得したいとします。NSPredicateはオブジェクトクラスの種類を確認します
"isKindOf:"で述語をコーディングする方法は?
私はUIView
の配列を持っています。この配列に- (NSArray *)filteredArrayUsingPredicate:(NSPredicate *)predicate
を呼び出して、MyCustomView
オブジェクトを取得したいとします。NSPredicateはオブジェクトクラスの種類を確認します
"isKindOf:"で述語をコーディングする方法は?
てみてください(がをdepracated)
[NSPredicate predicateWithFormat: @"className == %@", [someObject className]]
それとも
[NSPredicate predicateWithFormat: @"class == %@", [someObject class]]
どのようにあなたのキーとして-className
を使用してはどうですか?
NSPredicate* foo = [NSPredicate predicateWithFormat: @"className == %@", @"MyCustomView"];
iOS APIでは '-className'のようなものは見えません... – user500
Jefの方法でエラーが発生しました。しかし、これは私のために働いた。
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"self isKindOfClass: %@", class];
作品。 – user500
私にとっても 'className'で動作します。 'class'はもっときれいに見えますが。 – Jef
さらに適切なのは何ですか? "="または "LIKE"? – user500