我有一個IPhone應用程序,其中有一個NSMutableArray
字典。當選擇表的每一行,我用如何從包含特定鍵的NSmutablearray中刪除所有字典?
if (indexPath.row <[self.newmessagearrays count])
{
[messagearrays removeObjectAtIndex:indexPath.row];
}
我有,我要刪除所有在我的「從標識」鍵相同的字典的情景,當行刪除字典被挖掘。我想這樣的,但沒有效果:
NSPredicate * pr = [NSPredicate predicateWithFormat:@"userid == %@",fromidstring];
[messagearrays filterUsingPredicate:pr];
我需要刪除字典中的fromid鍵是一個特定值的所有字典,比如說190 ... – hacker 2013-02-27 08:20:57
這不是你的答案中的情況,我懷疑 – hacker 2013-02-27 08:22:51
@hacker不,這不清楚我(在原始問題中)。上面的代碼將刪除數組中所有包含鍵「SOME_KEY」的值(* any * value)的字典。您在澄清中描述的謂詞可以寫爲:'NSPredicate * pr = [NSPredicate predicateWithBlock:^(id evaluateObject,NSDictionary * bindings){return(BOOL)![[evaluateObject objectForKey:@「fromid」] isEqual:@「190 「];}];' – justin 2013-02-27 08:42:55