Ios NSDictionary的EXC\u错误\u访问错误

Ios NSDictionary的EXC\u错误\u访问错误,ios,objective-c,json,memory-management,Ios,Objective C,Json,Memory Management,当我从JSON文件获取数据时,我得到一个错误->EXC\u BAD\u ACCESS 我没有使用ARC,以下是我的代码: -(void)fetchedData:(NSData*)responseData { NSError *error; NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];

当我从JSON文件获取数据时,我得到一个错误->
EXC\u BAD\u ACCESS

我没有使用ARC,以下是我的代码:

    -(void)fetchedData:(NSData*)responseData
{
    NSError *error;
    NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];

    fetchedResutsArray = [json objectForKey:@"People"];

    NSLog(@"%@", fetchedResutsArray);
    [self.tableView reloadData];
}

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *CellIdentifier = @"Cell";
    //OrderCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    // Configure the cell...
    NSDictionary *resultsDict = [fetchedResutsArray objectAtIndex:indexPath.row];

    cell.textLabel.text = [resultsDict objectForKey:@"prename"];

    return cell;
}
这是我的JSON结果。我从网站上获取数据 JSON:

Xcode在NSLOG中显示了这一点

fetchedResutsArray = [json objectForKey:@"People"];
这将创建一个自动释放的对象,该对象迟早会被释放。您不能在该方法之外访问此对象。您违反了内存管理规则

您可以保留该对象,这将解决您的问题

[fetchedResutsArray release]; // release old instance
fetchedResutsArray = [[json objectForKey:@"People"] retain];
或者使用retain@属性并通过使用
self.fetchedResutsArray=[json objectForKey:@“People”]分配对象。
不要忘记在
dealloc


或者干脆用弧线

你能分享你的json结构吗?不,我不是在使用ARCPost,而是你在nslog中得到的结果。我会使用'Just use ARC'位^。
[fetchedResutsArray release]; // release old instance
fetchedResutsArray = [[json objectForKey:@"People"] retain];