我使用tableview从json文件填充数组...在我看来控制器我有tableview.when我运行项目我的表视图编码不执行。我不知道y?任何人都可以帮助我pls.This是我的视图控制器文件使用TableView填充数组的JSON
#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;
}
在上面的代码中有一个NSLog也没有执行.. – 2011-12-22 06:14:34
我认为你正在寻找[xSON中的JSON解析](http://sugartin.info/2011/10/19/json-parsing-in -xcode /)。 – 2011-12-22 06:19:33
你一定忘记为数据源设置委托。 – samfisher 2011-12-22 07:03:11