0

我正在使用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; 
} 
+0

如果您在崩潰前記錄'singleUserDetail'或'userDetailsArray'的值,您會看到什麼? –

+0

@PhillipMills它崩潰而沒有記錄任何值。 – southpark

回答

0

我會試着讓你們班userDetailsArray一個財產和使用self.userDetailsArray其價值和參考設置它。

(很奇怪的是,陣列有效期爲count而不是稍後訪問,但釋放的內存似乎是最合乎邏輯的解釋。)

您也可以嘗試打開殭屍爲您的構建方案,看看是否提供更好的信息。

+0

謝謝!有效.. – southpark

相關問題