I have the following array of dictionaries:
Printing description of newOrderbookBids:
<__NSArrayI 0x10053e7c0>(
{
price = "10.14";
size = 148;
},
{
price = "10.134";
size = 0;
},
{
price = "10.131";
size = 321;
})
Each dictionary in the array has the keys price and size, both are numbers.
I would like to return a filtered array which contains only the dictionaries for which size > 0. In this example, this would be the array with dictionary #1 and #3, but without dictionary #2:
({
price = "10.14";
size = 148;
},
{
price = "10.131";
size = 321;
})
I have tried the following code snippet to filter my NSArray *newOrderbookBids by size:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"size > 0"];
newOrderbookBids = [newOrderbookBids filteredArrayUsingPredicate:predicate];
Unfortunately my code crashes with the runtime error
[NSSymbolicExpression compare:]: unrecognized selector sent to instance xxxx
What is wrong with my code and predicate?
How can I filter by size > 0?
Thank you!