0
我該如何解析這個https://coinbase.com/api/v1/prices/historical?到x(時間)和y(價格)數組中以創建使用核心圖(或其他建議)的折線圖?我到這裏:解析Json數據核心 - 陰謀
-(void)URL
{
dispatch_async(coinbaseQueue, ^{
NSString* coinbaseURL= @"https://coinbase.com/api/v1/prices/historical?";
NSData* data = [NSData dataWithContentsOfURL: [NSURL URLWithString:coinbaseURL]];
if (data == nil)
{
NSLog(@"url: loading ERROR");
[NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(URL) userInfo:nil repeats:YES];//was NO
}else
{
[self performSelectorOnMainThread:@selector(fetchedData:) withObject:data waitUntilDone:YES];
}
});
}
- (void)fetchedData:(NSData *)responseData {
//parse out the json data
NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData //1
options:kNilOptions
error:&error];
//parse
}
還有任何進一步的幫助,鏈接到核心劇情教程。非常感謝 謝謝!
我遇到了麻煩:「然後每行都做同樣的事情,但這次用逗號作爲分隔符」第二個「現在數據是數組NSString的coponentsSeparatedByString不起作用我的數組看起來像:」2014- 03-14T20:46:58-07:00,634.95「, 」2014-03-14T20:37:24-07:00,632.12「, 」2014-03-14T20:26:59-07:00,634.01「,...此外,一旦用逗號分隔並轉換爲NSDate/NSNumber,我如何將其他每行分隔爲x和y數組?謝謝! – valmassoi