0

I m using tableview to populate an array from json file...In my view Controller i have tableview.when i run the project my table view codings are not executing.i dont know y?anyone help me pls.This is my viewcontroller file

#import "JSONparserViewController.h"
    @implementation JSONparserViewController
    @synthesize arraydata;

    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Release any cached data, images, etc that aren't in use.
    }


    #pragma mark - View lifecycle

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


    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 {
        NSLog(@"No Of Elements in Array Data: %d",[arraydata count]);
        return [arraydata count];
 }

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        return 80;
    }


    // Customize the appearance of table view cells.
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

        static NSString *CellIdentifier = @"Cell";

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
        }

        // Configure the cell...
         NSLog(@"%@",arraydata);
        NSDictionary *aTweet = [arraydata objectAtIndex:[indexPath row]];
        cell.textLabel.text = [aTweet objectForKey:@"name"];
        //    NSDictionary *newArray=[aTweet objectForKey:@"properties"];
        //   
        //    NSDictionary *newArray1=[newArray objectForKey:@"propertyMeta"];
        //    cell.detailTextLabel.text = [newArray1 objectForKey:@"name"];
        //    cell.detailTextLabel.text = [newArray objectForKey:@"value"];
        cell.textLabel.adjustsFontSizeToFitWidth = YES;
        cell.textLabel.font = [UIFont systemFontOfSize:12];
        cell.textLabel.minimumFontSize = 10;
        cell.textLabel.numberOfLines = 4;
        cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;

        //cell.detailTextLabel.text = [newArray1 objectForKey:@"type"];

        //  NSURL *url = [NSURL URLWithString:[aTweet objectForKey:@"profile_image_url"]];
        //  NSData *data = [NSData dataWithContentsOfURL:url];
        //  cell.imageView.image = [UIImage imageWithData:data];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        NSLog(@"HIIIIIIIIII");
        return cell;

    }
iCreative
  • 1,499
  • 1
  • 9
  • 22
Dinesh Raja
  • 8,501
  • 5
  • 42
  • 81

5 Answers5

0

have you initialized your arraydata object...? and also it looks to me that you haven't set the delegate and datasource for your tableview becoz of which your nslog delegate methods are not being called.

Ankit Srivastava
  • 12,347
  • 11
  • 63
  • 115
  • I already initialized arraydata and also set both both delegate and datasource.still i havent clear this issue...i m one of the error also that is "Applications are expected to have a root view controller at the end of application launch" – Dinesh Raja Dec 22 '11 at 09:09
0

Do this to set the delegate and datasource of tableView in your header file.

@interface JSONparserViewController: UIViewController<UITableViewDelegate,UITableViewDataSource>

{

}

Also check that your arraydata array is given memory or not.If not give it the memory first

Anil Kothari
  • 7,653
  • 4
  • 20
  • 25
0

you have nit allocate your array. firstly you have to allocate your Array wherever you assign your array value . NSLog your array in view will appear if printed then it must be executed

Hiren
  • 12,720
  • 7
  • 52
  • 72
0

Your Problem is you dont have any data in the arraydata object. Its count is zero. So Although you have set all delegate & datasource, Your table delegate methods will not called, because when it calls noofrowinSection, it returns zero.

Please verify that you have data in your arrayObject.

iCreative
  • 1,499
  • 1
  • 9
  • 22
  • Actually In my array i m setting data from AppDelegate.Before i set the array value UITableView loaded into simulator.So that array value returns zero and i m not getting my tableview with data.Anyway Thanks Buddy...I found out that just before...Your are correct! – Dinesh Raja Dec 23 '11 at 19:26
0

Please verify you have data in your array. And once after parsing is done, then reload the table in connectiondidfinishloading method. Table will be automatically reload.

P.J
  • 6,547
  • 9
  • 44
  • 74
Shynu
  • 1