0

タブバーアプリケーションを使用しています。タブの1つに、SplitViewとして埋め込まれたtableViewコントローラーがあります。このタブがアクティブになったら、URL呼び出しを行って、サーバーからデータを取得します。tableViewにデータを入力できません。'[self.tableView reloadData]'を試しましたが、アプリケーションがクラッシュします。私のViewControllerクラスはUITableViewControllerにサブクラス化されています。

- (void)didReceiveUserListFromServer
{
NSData *jsonData = responseData;
NSError *error=nil;

NSMutableDictionary *responseDict = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONWritingPrettyPrinted error:&error];
userDetailsArray = [responseDict objectForKey:@"userDetails"];
NSLog(@"count===%d",[userDetailsArray count]);   //This returns a non-zero number
[self.tableView reloadData];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [userDetailsArray count];
}

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

static NSString *CellIdentifier = @"ReturningPatientSearchResultCell";

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



NSMutableDictionary *singleUserDetail = [userDetailsArray objectAtIndex:indexPath.row];
cell.textLabel.text=[singleUserDetail objectForKey:@"Name"];  //EXC_BAD_ACCESS here

return cell;
}
4

1 に答える 1

0

クラスで強力なプロパティを作成し、その値とその参照を設定するために使用してみuserDetailsArrayます。self.userDetailsArray

(アレイが後でアクセスするために有効であり、有効ではないのは奇妙ですcountが、解放されたメモリは最も論理的な説明のようです。)

ビルドスキームでゾンビをオンにして、より良い情報が得られるかどうかを確認することもできます。

于 2012-09-24T14:24:19.727 に答える