親愛的程序員。 我必須連接到一個API,並使用我回來的JSON將它存儲在一個表中。 使用AFnetworking,Xcode和ios。 到目前爲止,它一直在給我一整天的時間,使我瘋狂。我已經嘗試了幾個教程和項目,但我無法讓它工作。在tableview中顯示JSON IOS Xcode
第一個問題是我似乎無法找到我的,我回來了JSON鍵..
當然,我不得不解析JSON,它並沒有真正對我也
工作能你請幫我把我的json放到桌面視圖中?
我使用的API是:https://api.9292.nl/0.1/locations?lang=nl-NL&q=amsterd
我在應用程序收到爲輸出 {
"locations": [
{
"id": "station-amsterdam-centraal",
"type": "station",
"stationId": "asd",
"stationType": "Station",
"name": "Amsterdam Centraal",
"place": {
"name": "Amsterdam",
"regionCode": "NH",
"regionName": "Noord-Holland",
"showRegion": false,
"countryCode": "NL",
"countryName": "Nederland",
"showCountry": false
},
"latLong": {
"lat": 52.378706,
"long": 4.900489
},
"urls": {
"nl-NL": "/station-amsterdam-centraal",
"en-GB": "/en/station-amsterdam-centraal"
}
等
The code I have right now is:
//
// ViewController.m
// 9292apiconnection
//
// Created by TheDutchBeast on 02-09-14.
// Copyright (c) 2014 Lambregts. All rights reserved.
//
#import "ViewController.h"
#import <AFNetworking/AFNetworking.h>
@interface ViewController()
@property (strong, nonatomic) NSDictionary *posts;
@property (strong, nonatomic) NSMutableArray *post;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"http://api.9292.nl/0.1/locations?lang=nl-NL&q=amsterd" parameters:nil success:^(
AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
請幫我確定從關鍵的JSON json代碼以及如何將這些值存入Xcode的表中,ios 。只有ID和名稱需要在表格中
請以教程沒有鏈接中顯示,因爲我已經看到他們事先都 感謝
你試過了什麼? http://meta.stackexchange.com/questions/122986/is-it-ok-to-leave-what-have-you-tried-comments – 2014-09-03 11:34:13