我有一個NSMutableArray的是這樣的:Objective C:用字典鍵的值過濾掉NSMutableArray的結果?
(
{
City = "Orlando";
Name = "Shoreline Dental";
State = Florida;
},
{
City = "Alabaster ";
Name = Oxford Multispeciality;
State = Alabama;
},
{
City = Dallas;
Name = "Williams Spa";
State = Texas;
},
{
City = "Orlando ";
Name = "Roast Street";
State = Florida;
}
)
現在我該怎麼解決這NSMutableArray中獲得相應於國家「佛羅里達」 我希望得到
(
{
City = "Orlando";
Name = "Shoreline Dental";
State = Florida;
},
{
City = "Orlando ";
Name = "Roast Street";
State = Florida;
}
)
我去這個代碼的結果,但它再次顯示前四個字典。
NSSortDescriptor *valueDescriptor = [[NSSortDescriptor alloc] initWithKey:@"Florida" ascending:YES];
NSArray * descriptors = [NSArray arrayWithObject:valueDescriptor];
NSArray * sortedArray = [arr sortedArrayUsingDescriptors:descriptors];
你真的不想排序數組,但檢索一個子數組,對吧? – 2012-12-24 07:56:56
是的,你對.. – Honey
是城市,名稱,州是一個對象的屬性?或直接在數組中? –