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 回答