Objective c 在主viewcontroller(Xcode5)中导入IOS6 JSON.H
我是ios新手,所以为了获得accesstoken,我遵循了链接Objective c 在主viewcontroller(Xcode5)中导入IOS6 JSON.H,objective-c,json,xcode,ios6,Objective C,Json,Xcode,Ios6,我是ios新手,所以为了获得accesstoken,我遵循了链接 。因此,在这些链接中,他们使用了json.h文件。如果是,请在这些链接中向我解释json github。这是您想要的链接 在项目中不强制使用JSON.h。现在您可以使用内置的apple JSON解析器。如果您想下载JSon库,则链接为 否则,您可以使用以下方法使用此内置的apple JSON解析器 NSDictionary *res = [NSJSONSerialization JSONObjectWithData:respo
。因此,在这些链接中,他们使用了json.h文件。如果是,请在这些链接中向我解释json github。这是您想要的链接
在项目中不强制使用JSON.h。现在您可以使用内置的apple JSON解析器。如果您想下载JSon库,则链接为 否则,您可以使用以下方法使用此内置的apple JSON解析器
NSDictionary *res = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves || NSJSONReadingMutableContainers error:&myError];
完整代码如下:
NSString *urlString=[NSString stringWithFormat:@"%@listcontact.php?uid=%@&page=0",LocalPath,appdel.strid]; //---- Add your URL for webservice-----
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
There are two NSURLConnection request methods AsynchronousRequest and SynchronousRequest.
(1) For AsynchronousRequest
[NSURLConnection sendAsynchronousRequest:urlRequest queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
NSError *error1;
NSDictionary *res=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error1];
}];
(2) For SynchronousRequest
NSData *GETReply = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:nil error:nil];
NSError *myError = nil;
NSDictionary *res = [NSJSONSerialization JSONObjectWithData:GETReply options:NSJSONReadingMutableLeaves error:&myError];
使用本机NSJSONSerialization类,您可以在下面的链接中找到更多信息
我想用apple JSON解析器解释一下你提供的代码,以及放在哪里和如何放?Thanks@ChetanKumar查看我的更新代码。如果您有任何疑问,请与我联系