0

以下のような NSMutableArray* を取得し、NSPredicate を使用してフィルタリングして、ステータスに基づいて関心のあるものだけを返すようにしようとしています。

実行後、結果変数が空になるため、何らかの理由でフィルタリングされません。アイデアはありますか?

ありがとう

コード:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"StatusId == %i", aOrderStatus ];
NSLog(@"%@", [predicate debugDescription]);
NSArray *result = [aOrdersList filteredArrayUsingPredicate: predicate];
NSLog(@"getRestaurantOrderList - result: %@", [result debugDescription]);
return [result mutableCopy];

aOrdersList 配列の内容:

{
    StatusId = 0;
    cost = "22.950000762939";
    name = "Pieter Uys";
    number = 0823630937;
    order = "1/4 Chicken - SPICE: L";
    "order detail" = "SPICE: L";
    "order title" = "1/4 Chicken";
    orderNo = 2;
    orderNoDisplay = ORD0000000002;
    quantity = 1;
    restaurant = Nandos;
    time = " 20 min ";
},
{
    StatusId = 0;
    cost = "41.950000762939";
    name = "Pieter Uys";
    number = 0823630937;
    order = "1/4 CHICKEN MEAL - Side: CHIPS, Drink: COKE, SPICE: L";
    "order detail" = "Side: CHIPS, Drink: COKE, SPICE: L";
    "order title" = "1/4 CHICKEN MEAL";
    orderNo = 3;
    orderNoDisplay = ORD0000000003;
    quantity = 1;
    restaurant = Nandos;
    time = " 20:00 ";
},
4

1 に答える 1

2

これを次のように行います: aOrderStatus

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(StatusId == %d)", aOrderStatus ];
NSArray *result = [aOrdersList filteredArrayUsingPredicate: predicate];
NSLog(@"getRestaurantOrderList - result: %@", [result debugDescription]);
于 2012-09-11T10:34:30.650 に答える