關鍵字排序問題:
每個dictionary對象有不同的數據類型,全部dictionary都當做string提取了,怎麼樣將這些string類型的數據轉換為不同類型,然後根據價格排序。
-(IBAction)PriceSort:(id)sender
{
NSSortDescriptor * sort = [[NSSortDescriptor alloc] initWithKey:@"Price" ascending:true] ;
NSArray *sa = [symbolArray sortedArrayUsingDescriptors:[NSArray arrayWithObject:sort]];
NSLog(@"price=%@",sa);
}
輸出:
{
volume = 2496752;
Yield = "10.49";
MarCap = 829;
Price = "0.715";
Symbol = SAIPI;
}
sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"price"
ascending:YES selector:@selector(localizedStandardCompare:)] ;