2012-04-16 15 views
0

の状態と等しい次の配列をフィルタリングする必要があります。 "U"と私は以下を使用しています。述語を使用したフィルタ配列

NSArray *result = [alertModified.senders filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(subscriptions.status = %@)",@"U"]]; 

しかし、私は空の配列を取得しています。

これをフィルタリングするのを手伝ってください。

アレイ文字列:あなたの例で

(senderCode = CPFB, senderName = CPFB, forSenderLevel = 0, subscriptions = (
"correspondenceListId = 102,status = S,senderCode = AA,subject = Letter,retentionPeriod = 0, uniqueBillIdentifier = (null),senderResponseStatus = (null),subscriptionDate = ,effectiveDate = ", 
"correspondenceListId = 103,status = U,senderCode = BB,subject = Nomination Letters,retentionPeriod = 0, uniqueBillIdentifier = (null),senderResponseStatus = (null),subscriptionDate = ,effectiveDate = ", 
"correspondenceListId = 104,status = U,senderCode = AA,subject = Yearly statements,retentionPeriod = 0, uniqueBillIdentifier = (null),senderResponseStatus = (null),subscriptionDate = ,effectiveDate = ", 
"correspondenceListId = 105,status = U,senderCode = BB,subject = All Future Letters,retentionPeriod = 0, uniqueBillIdentifier = (null),senderResponseStatus = (null),subscriptionDate = ,effectiveDate = ")) 
+0

したがって、**サブスクリプション**、または文字列全体を何らかの形で並べ替える必要がありますか? –

+0

コンマで区切られた文字列ですか? – wbyoung

+0

私はソートする必要はありませんが、ステータスが「U」であるレコードをフィルタリングする必要があります。つまり、上から3レコードしか取得できません。上記の文字列は、オブジェクト階層の表現です。 – lasi

答えて

0

は、サブスクリプション・リスト自体ではなく、全体の送信者をフィルタリングする必要があります。各送信者にフィルタを適用する必要があります。フィルタ行をこれに変更して、結果が得られるかどうかを確認してください。

NSArray *result = [[alertModified.senders objectAtIndex:0].subscriptions filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(status = %@)",@"U"]]; 
+0

ありがとうございました。しかし、私は配列内ではなく、入れ子にされた配列を繰り返したい。単一のリスト内のコードスニペットフィルタ。 – lasi

関連する問題