The following code works just fine:
NSArray *array = @[
@{
@"Carton_Apartment" : @"",
@"Carton_AreaCode" : @111,
@"Carton_AreaGroupCode" : @1,
@"Carton_AreaGroupName" : @"Group1",
@"Carton_AreaName" : @"Bayan",
@"Carton_Avenue" : @"",
@"Carton_Block" : @1,
@"Carton_CartonNumber" : @1,
@"Carton_CustomerCode" : @6880,
@"Carton_CustomerName" : @"Name 1",
@"Carton_DeliveryNotes" : @YES,
@"Carton_DeliveryShiftCode" : @1,
@"Carton_DietType" : @"LBS-750",
@"Carton_Floor" : @"",
@"Carton_HomeNo" : @45,
@"Carton_HomePhone" : @111111,
@"Carton_IsDelivered" : @NO,
@"Carton_Latitude" : @"",
@"Carton_Longitude" : @"",
@"Carton_Mobile" : @1111111,
@"Carton_OfficePhone" : @"",
@"Carton_StreetName" : @2,
@"Carton_SubscriptionDate" : @"2014-04-29T00:00:00",
@"Carton_Title" : @"Mrs."
},
@{
@"Carton_Apartment" : @"",
@"Carton_AreaCode" : @111,
@"Carton_AreaGroupCode" : @1,
@"Carton_AreaGroupName" : @"Group1",
@"Carton_AreaName" : @"Bayan",
@"Carton_Avenue" : @"",
@"Carton_Block" : @1,
@"Carton_CartonNumber" : @2,
@"Carton_CustomerCode" : @8314,
@"Carton_CustomerName" : @"Name 2",
@"Carton_DeliveryNotes" : @YES,
@"Carton_DeliveryShiftCode" : @1,
@"Carton_DietType" : @"ND1350",
@"Carton_Floor" : @"",
@"Carton_HomeNo" : @45,
@"Carton_HomePhone" : @222222,
@"Carton_IsDelivered" : @NO,
@"Carton_Latitude" : @"",
@"Carton_Longitude" : @"",
@"Carton_Mobile" : @111111,
@"Carton_OfficePhone" : @"",
@"Carton_StreetName" : @2,
@"Carton_SubscriptionDate" : @"2014-04-29T00:00:00",
@"Carton_Title" : @"Mr."
}
];
NSPredicate *predFilter = [NSPredicate predicateWithFormat:
[NSString stringWithFormat:@"Carton_CartonNumber = %d", 2]];
NSLog(@"%@", [array filteredArrayUsingPredicate:predFilter]);
Your problem is not with the predicate you're using.
Update
I was wrong and it is
the predicate that's the problem, as you've stated in the comments that Carton_CartonNumber
is a string. I updated the above code to be:
NSArray *array = @[
@{
@"Carton_Apartment" : @"",
@"Carton_AreaCode" : @111,
@"Carton_AreaGroupCode" : @1,
@"Carton_AreaGroupName" : @"Group1",
@"Carton_AreaName" : @"Bayan",
@"Carton_Avenue" : @"",
@"Carton_Block" : @1,
@"Carton_CartonNumber" : @"1",
@"Carton_CustomerCode" : @6880,
@"Carton_CustomerName" : @"Name 1",
@"Carton_DeliveryNotes" : @YES,
@"Carton_DeliveryShiftCode" : @1,
@"Carton_DietType" : @"LBS-750",
@"Carton_Floor" : @"",
@"Carton_HomeNo" : @45,
@"Carton_HomePhone" : @111111,
@"Carton_IsDelivered" : @NO,
@"Carton_Latitude" : @"",
@"Carton_Longitude" : @"",
@"Carton_Mobile" : @1111111,
@"Carton_OfficePhone" : @"",
@"Carton_StreetName" : @2,
@"Carton_SubscriptionDate" : @"2014-04-29T00:00:00",
@"Carton_Title" : @"Mrs."
},
@{
@"Carton_Apartment" : @"",
@"Carton_AreaCode" : @111,
@"Carton_AreaGroupCode" : @1,
@"Carton_AreaGroupName" : @"Group1",
@"Carton_AreaName" : @"Bayan",
@"Carton_Avenue" : @"",
@"Carton_Block" : @1,
@"Carton_CartonNumber" : @"2",
@"Carton_CustomerCode" : @8314,
@"Carton_CustomerName" : @"Name 2",
@"Carton_DeliveryNotes" : @YES,
@"Carton_DeliveryShiftCode" : @1,
@"Carton_DietType" : @"ND1350",
@"Carton_Floor" : @"",
@"Carton_HomeNo" : @45,
@"Carton_HomePhone" : @222222,
@"Carton_IsDelivered" : @NO,
@"Carton_Latitude" : @"",
@"Carton_Longitude" : @"",
@"Carton_Mobile" : @111111,
@"Carton_OfficePhone" : @"",
@"Carton_StreetName" : @2,
@"Carton_SubscriptionDate" : @"2014-04-29T00:00:00",
@"Carton_Title" : @"Mr."
}
];
NSPredicate *predFilter = [NSPredicate predicateWithFormat:
[NSString stringWithFormat:@"Carton_CartonNumber = \"%d\"", 2]];
NSLog(@"%@", [array filteredArrayUsingPredicate:predFilter]);
You'll find the proper predicate that you're looking for in the updated code above.