JSON和Iphone表加载,I';我滚动时遇到EXC\u BAD\u访问错误

JSON和Iphone表加载,I';我滚动时遇到EXC\u BAD\u访问错误,iphone,json,uitableview,Iphone,Json,Uitableview,我花了很长时间试图弄明白为什么我会遇到一个EXC_错误的访问错误。控制台给了我这个eror:“-[CFArray objectAtIndex:]:消息发送到解除分配的实例0x3b14110”,我搞不懂…提前谢谢 // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { re

我花了很长时间试图弄明白为什么我会遇到一个EXC_错误的访问错误。控制台给了我这个eror:“-[CFArray objectAtIndex:]:消息发送到解除分配的实例0x3b14110”,我搞不懂…提前谢谢

// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [rowsArray count];
}


// 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] autorelease];
}

// Configure the cell.
NSDictionary *dict = [rows objectAtIndex: indexPath.row];

cell.textLabel.text = [dict objectForKey:@"name"];
cell.detailTextLabel.text = [dict objectForKey:@"age"];


return cell;
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.0/255.0 green:207.0/255.0 blue:255.0/255.0 alpha:1.0];
self.title = NSLocalizedString(@"NOW", @"NOW");
NSURL *url = [NSURL URLWithString:@"http://10.0.1.8/~imac/iphone/jsontest.php"];
NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:url];

//  NSLog(jsonreturn); // Look at the console and you can see what the restults are

NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding];
NSError *error = nil;

// In "real" code you should surround this with try and catch
NSDictionary * dict = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error];
if (dict)
{
    rowsArray = [dict objectForKey:@"member"];
}

NSLog(@"Array: %@",rowsArray);
    NSLog(@"count is: %i", [self.rowsArray count]);


[jsonreturn release];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
    }

- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
    }

 @end

看起来,
是一个实例变量,用于保存要显示的数据?如果是这样,则在分配时不会保留它。记住:如果你想保留一个对象,你必须声明它的所有权。实现这一点的方法是自己分配它,或者
保留
/
复制
在别处分配的对象

这项任务

rows = [dict objectForKey:@"member"];
他不会那样做的。这意味着
将被解除分配,并最终持有对解除分配对象的引用


另外,
rowsArray
rows
之间有什么区别?如何确保
rowsArray
返回的
count
相同?通常,您应该在所有
UITableViewDataSource
方法中使用相同的数据源。

崩溃发生在哪一行?