reloadData в tableView дает сбой при использовании с uisplitviewController внутри контроллера панели вкладок

Я работаю с приложением с вкладками. На одной из вкладок у меня есть контроллер tableView, встроенный как SplitView. Когда эта вкладка становится активной, я делаю 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;
}

person southpark    schedule 24.09.2012    source источник
comment
Что вы увидите, если запишете значение singleUserDetail или userDetailsArray непосредственно перед сбоем?   -  person Phillip Mills    schedule 24.09.2012
comment
@PhillipMills Вылетает без регистрации каких-либо значений.   -  person southpark    schedule 24.09.2012


Ответы (1)


Я бы попробовал сделать userDetailsArray свойством strong в вашем классе и использовать self.userDetailsArray для установки его значения и ссылок на него.

(Странно, что массив действителен для count, а не для более позднего доступа, но освобожденная память кажется наиболее логичным объяснением.)

Вы также можете попробовать включить зомби для своей схемы сборки и посмотреть, даст ли это лучшую информацию.

person Phillip Mills    schedule 24.09.2012