2016-04-03 7 views
0

jsonを取得してnsstringに格納する次のコードがありますが、nsdictionary..iに格納する必要があります。私のためのソリューションは、事前に私にjsonと私はnsstringに格納することができますが、nsdringにそのnsstringデータを格納します。

[request setHTTPMethod:@"GET"]; 
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; 
[[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { 

    NSString *requestReply = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 

    NSString *outfinal=[requestReply stringByReplacingOccurrencesOfString:@"\\""" withString:@""]; 

      NSLog(@"sender id array: %@", outfinal); 




}] resume]; 

答えて

0

てみ感謝を..help:方法は次の

NSDictionary * json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; 
              NSLog(@"%@",json); 
0

てみてください、それは間違いなくあなたを助けます。 URLを置き換えることを忘れないでください。

NSURL *url = [[NSURL alloc] initWithString:@"Replace your URL here"]; 

[NSURLConnection sendAsynchronousRequest:[[NSURLRequest alloc] initWithURL:url] queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) 
{ 
    NSMutableArray * jsonData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error]; 
    if (error) 
     NSLog(@"JSONObjectWithData error: %@", error); 
    else 
     { 
    // Enter your code here to use Json Objects Store in JsonData(NSMutablearray) 
    }); 
}]; 

アレイ、使用次のコードに格納されたオブジェクトの値を取得するには:

[[jsonData objectAtIndex:0] objectForKey:@"Key for retrieving value from Object"]; 
+0

を私はNSURLConnectionを使用するときにハイテク本当にお返事とiOS9を使用していてくれてありがとうはそれがある..so iOS9で廃止予定の表示それは私に何かエラーを表示する? –

関連する問題