Following is the array of dictionary:
{
DATA: [
{
GAMEID: 509782,
FIELDNUMBER: "KPB #1",
},
{
GAMEID: 509782,
FIELDNUMBER: "KPB #1",
},
{
GAMEID: 509782,
FIELDNUMBER: "KPB #1",
},
{...
Now I want to filter the array based on GAMEID
. For this I am creating a loop and inside that am using NSPredicate
. Following is my code:
func callSort(arr:NSMutableArray) -> NSMutableDictionary {
var arrId = arr.valueForKey("GAMEID")
for(index, ele) in arrGames.enumerate() {
let str = ele.valueForKey("GAMEID")
let pred = NSPredicate(format: "ANY DATA.GAMEID == %@", argumentArray: str) // error on this line
var filterArr = arrGames.filteredArrayUsingPredicate(pred)
}
return sortedDict
}
The error I get is:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse function name 'Optional:' into supported selector (Optional:)
I am not sure if I am using the NSPredicate
the right way.
Where am I getting wrong? How do I solve this?
Edited Code
let pred = NSPredicate(format: "GAMEID = %d", argumentArray: [str!])
var filterArr = arrGames.filteredArrayUsingPredicate(pred)