亲爱的程序员。 我必须连接到一个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