2016-01-30 2 views
-3
"SPECIFICATIONS":[ 
     { 
     "NAME": "Brand", 
     "CODE": "CML2_MANUFACTURER", 
     "VALUE": "Samsung" 
     }, 
     { 
     "NAME": "Model", 
     "CODE": "MODEL", 
     "VALUE": "Galaxy Ace 3 S7262" 
     }, 
     { 
     "NAME": "Color", 
     "CODE": "COLOR", 
     "VALUE": "Black" 
     }, 
     { 
     "NAME": "Operating System", 
     "CODE": "OPERATING_SYSTEM", 
     "VALUE": "Android" 
     }, 
     { 
     "NAME": "OS Version", 
     "CODE": "OS_VERSION", 
     "VALUE": "Android 4.1+ (Jelly Bean)" 
     }, 
     { 
     "NAME": "Screen Size", 
     "CODE": "SCREEN_SIZE", 
     "VALUE": "4 inch" 
     }, 
     { 
     "NAME": "Screen Type", 
     "CODE": "SCREEN_TYPE", 
     "VALUE": "TFT - Capacitive Touchscreen" 
     }, 
     { 
     "NAME": "Display Type", 
     "CODE": "DISPLAY_TYPE", 
     "VALUE": "Touchscreen" 
     }, 
     { 
     "NAME": "SIM Support", 
     "CODE": "SIM_SUPPORT", 
     "VALUE": "Dual SIM" 
     }, 
     { 
     "NAME": "SIM Type", 
     "CODE": "SIM_TYPE", 
     "VALUE": "Micro SIM" 
     }, 
     { 
     "NAME": "Data", 
     "CODE": "CONNECTIVITY", 
     "VALUE": "2G" 
     }, 
     { 
     "NAME": "Connectivity", 
     "CODE": "DATA", 
     "VALUE": "WiFi, EDGE, GPRS, Bluetooth, USB" 
     }, 
     { 
     "NAME": "Storage", 
     "CODE": "MEMORY", 
     "VALUE": "4GB" 
     }, 
     { 
     "NAME": "RAM", 
     "CODE": "RAM", 
     "VALUE": "512MB" 
     }, 
     { 
     "NAME": "Processor Type", 
     "CODE": "PROCESSOR_TYPE", 
     "VALUE": "Dual-core 1 GHz Cortex-A9" 
     }, 
     { 
     "NAME": "Camera", 
     "CODE": "CAMERA", 
     "VALUE": "Back Camera" 
     }, 
     { 
     "NAME": "Camera Type", 
     "CODE": "CAMERA_TYPE", 
     "VALUE": { 
      "Primary": "2 MP" 
     } 
     }, 
     { 
     "NAME": "Media Ports", 
     "CODE": "MEDIA_PORTS", 
     "VALUE": { 
      "Card Slot": "microSD, up to 32 GB", 
      "USB": "microUSB v2.0" 
     } 
     } 
    ] 
+0

вы можете показать ваш код попробовали –

+0

Im новым для прошивки, поэтому мне хотелось знать, как я разбираю это в виде таблицы. Может ли помочь? – user3355310

+0

Вы хотите весь код для этого? –

ответ

0

решения для Вашего вопроса

.h

#import <UIKit/UIKit.h> 

@interface ViewController : UIViewController<UITableViewDataSource,UITableViewDelegate> 
@property (strong, nonatomic) IBOutlet UITableView *tableViewJsonParse; 

@end 

.m

#import "ViewController.h" 

@interface ViewController() 
{ 
    NSMutableArray *arrName; 
    NSMutableArray *arrCode; 
    NSMutableArray *arrValue; 
} 

@end 

@implementation ViewController 

@synthesize tableViewJsonParse; 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
    [self getJSONResponse]; 
    [tableViewJsonParse reloadData]; 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

-(void)getJSONResponse 
{ 
    //I don't know your url.So you need to give the URL here and also you need to set GET method for getting response from server. 
    //Then follow the usual lines 
    NSData *data = [responseString dataUsingEncoding:NSUTF8StringEncoding]; 
    NSError *error; 
    NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; 
    NSArray *arr = jsonDict[@"SPECIFICATIONS"]; 
    arrName = [[NSMutableArray alloc]init]; 
    arrCode = [[NSMutableArray alloc]init]; 
    arrValue = [[NSMutableArray alloc]init]; 
    for(int i=0;i<[arr count];i++) 
    { 
     NSString *strName = [arr[i]objectForKey:@"NAME"]; 
     NSString *strCode = [arr[i]objectForKey:@"CODE"]; 
     NSString *strValue = [arr[i]objectForKey:@"VALUE"]; 

     NSLog(@"The strName is - %@",strName); 
     NSLog(@"The strCode is - %@", strCode); 
     NSLog(@"The strValue is - %@", strValue); 

     [arrName addObject:strName]; 
     [arrCode addObject:strCode]; 
     [arrValue addObject:strValue]; 

     NSLog(@"The arrName is - %@",arrName); 
     NSLog(@"The arrCode is - %@", arrCode); 
     NSLog(@"The arrValue is - %@", arrValue); 
    } 
} 

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    return 1; 
} 

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return arrName.count; 
} 
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *strCell = @"Cell"; 
    UITableViewCell *cell = [tableViewJsonParse dequeueReusableCellWithIdentifier:strCell]; 
    if(cell==nil) 
    { 
     cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:strCell]; 
    } 
    cell.textLabel.text = arrName[indexPath.row]; 
    cell.detailTextLabel.text = arrValue[indexPath.row]; 

    return cell; 
    } 
@end 
+0

Если мой ответ вам полезен, любезно пометьте мой ответ. – user3182143

Смежные вопросы