Wednesday, 20 February 2013





HI THIS TOUTORIAL WILL HELP FULL FOR STARTUP IN IOS CREATED BY NAVEENRAJU




IOS BASICS EXPLINATIONS BY NAVEENRAJU


JSon IN Table View






















Code For Above Demo:


MasterViewController.h

//
//  MasterViewController.h
//  Table_JsonDemo
//
//  Created by apple on 19/02/13.
//  Copyright (c) 2013 apple. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface MasterViewController : UITableViewController
{



}
@property(nonatomic,retain)NSURL *jsonUrl;
@property(nonatomic,retain)NSString *jsonData;
@property(nonatomic,retain)NSMutableArray *jsonArray;

@end



MasterViewController.m


//
//  MasterViewController.m
//  Table_JsonDemo
//
//  Created by apple on 19/02/13.
//  Copyright (c) 2013 apple. All rights reserved.
//

#import "MasterViewController.h"

#import "DetailViewController.h"
#import "SBJson.h"
@interface MasterViewController () {
    NSMutableArray *_objects;
}
@end

@implementation MasterViewController
@synthesize jsonArray;
@synthesize jsonData;
@synthesize jsonUrl;


- (void)viewDidLoad
{
    [super viewDidLoad];
    
    
    self.title=@"Jon Data IN TableView";
    jsonUrl=[NSURL URLWithString:@"http://localhost/App1/rac.php"];
    jsonData=[[NSString alloc]initWithContentsOfURL:jsonUrl];
    self.jsonArray=[jsonData JSONValue];
    NSLog(@"%@",jsonArray);
    
}




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









- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return jsonArray.count;
}







- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

    //NSDate *object = _objects[indexPath.row];
    cell.textLabel.text = [self.jsonArray objectAtIndex:indexPath.row];
    return cell;
}

@end

ViewController.xib





No comments:

Post a Comment