我從Web服務獲取數據,我將它放到NSDictionary
,並且使用valueForKey
方法,我將數據綁定到一個數組中,它有17個元素,但計數顯示爲1,因爲第一個數據有雙引號。這裏的示例代碼:Nsdictionary錯誤地顯示數據
- (void)BarChartfetchedData:(NSData *)responseData {
NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
BarChartDictionary = [json objectForKey:@"Report_DashboardDetailProfitBranchResult"];
NSArray * new = [[NSArray alloc]initWithObjects:[BarChartDictionary valueForKey:@"ProfitAmount"],nil];
NSLog(@"mypieclass.itemArray: %@ ",new);
NSLog(@"Total: %lu ",(unsigned long)[new count]);
NSLog(@"BarChartDictionary: %lu ",(unsigned long)[BarChartDictionary count]);
}
需要得到總數17.如何做到這一點,任何建議將是有益的。
您應該向我們顯示數據。 – vikingosegundo
這個問題錯過了重要的信息。它是關於解析,但是不需要顯示需要解析的數據。 – vikingosegundo
我添加了nslog圖像,但沒有10個聲望我無法添加圖像。 –