2 Mar 2017

NSJSONSerialization Code to get Data Code..


NSJSONSerialization Code to get Data Code..





#import "ViewController.h"
@interface ViewController ()
{
    NSMutableArray * arr,*priceArr1;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSError *error;
    arr = [[NSMutableArray alloc]init];
    priceArr1 = [[NSMutableArray alloc]init];
    
   self.jsonDix = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfURL: [NSURL URLWithString:[NSString stringWithFormat: @"https://itunes.apple.com/us/rss/topaudiobooks/limit=10/json"]]] options:kNilOptions error:&error];
    
    for (int i=0; i<9; i++)
    {
        
        NSLog(@"Parsed json data is ::::: %@ \n", [[[[[_jsonDix objectForKey:@"feed" ]objectForKey:@"entry"]objectAtIndex:i]objectForKey:@"title"]objectForKey:@"label"]);
        
        [arr addObject: [[[[[_jsonDix objectForKey:@"feed" ]objectForKey:@"entry"]objectAtIndex:i]objectForKey:@"title"]objectForKey:@"label"]];
        //NSLog(@"array elements are === %@",[arr objectAtIndex:i]);
        
        [priceArr1 addObject: [[[[[_jsonDix objectForKey:@"feed" ]objectForKey:@"entry"]objectAtIndex:i]objectForKey:@"im:price"]objectForKey:@"label"]];
       NSLog(@"array elements are === %@",[priceArr1 objectAtIndex:i]);
    }
    

}

No comments:

Post a Comment

Recent Posts

Codable demo

Link: https://www.dropbox.com/s/kw7c1kgv1628bh7/codableDemo.zip?dl=0