過濾詞典的陣列I具有字典的以下數組:通過使用謂詞
Printing description of newOrderbookBids:
<__NSArrayI 0x10053e7c0>(
{
price = "10.14";
size = 148;
},
{
price = "10.134";
size = 0;
},
{
price = "10.131";
size = 321;
})
陣列中的每個字典具有鍵price
和size
,無論是數字。
我想返回一個已過濾的數組,其中只包含size > 0
的字典。在這個例子中,這將是與字典#1和#3的排列,但沒有字典#2:
({
price = "10.14";
size = 148;
},
{
price = "10.131";
size = 321;
})
我曾嘗試下面的代碼段按大小篩選我NSArray *newOrderbookBids
:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"size > 0"];
newOrderbookBids = [newOrderbookBids filteredArrayUsingPredicate:predicate];
不幸的是我的代碼與運行時錯誤
[NSSymbolicExpression compare:]: unrecognized selector sent to instance xxxx
什麼是錯我的代碼和謂語崩潰? 我如何過濾size > 0
?
謝謝!
完美!這是解決方案! – AlexR