我正在使用tabbar應用程序。在其中一個選項卡中,我有一個嵌入爲SplitView的tableView控制器。當這個選項卡變爲活動狀態時,我會進行URL調用以從服務器獲取一些數據。我無法填充tableView中的數據。我試過'[self.tableView reloadData]',但應用程序崩潰。我的ViewController類被分類到UITableViewController。當在tabbar控制器中與uisplitviewController一起使用時,tableView崩潰時reloadData
- (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;
}
如果您在崩潰前記錄'singleUserDetail'或'userDetailsArray'的值,您會看到什麼? –
@PhillipMills它崩潰而沒有記錄任何值。 – southpark