2017-01-12 2 views
1

自分のカテゴリにオブジェクトをリンクしています。RLMLinkingObjects(Realm)のiOS述語

@property (readonly) RLMLinkingObjects *relatedAttachments; 

関連するアタッチメントがあればカテゴリに入れたいです。私はこれを試してみる。

NSPredicate *pred = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"relatedAttachments.count > 0"]]; 

self.categories = [[Category objectsWithPredicate:pred] sortedResultsUsingProperty:@"id" ascending:YES]; 

このようなエラーが発生しました。

"無効なプロパティ名" @ RLMPrecondition(プロパティ、

だから私は

NSPredicate *pred = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"relatedAttachments.count!=nil"]]; 
NSPredicate *pred = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"relatedAttachments.count!=NULL"]]; 

。他でみてください。しかし、それはまだ大丈夫ではありません。どのように?

を行うもの

答えて

1

次のような述語を探しています:

@countは、右側に表示されるコレクション内の要素の数を評価するコレクション演算子です。

+0

ありがとうございます。できます。 –