2012-05-25 33 views
0

我使用xCode 4.2構建iPhone應用程序。NSBundle mainBundle給出sigabrt錯誤?

相關問題 - 我認爲這可能是真正的問題,我遇到: Why does tableView dequeueReusableCellWithIdentifier:CellIdentifier return null?

但讓我繼續這個quesiton反正:

有一些事情,讓我行[[NSBundle mainBundle] loadNibNamed:@"WSCSessionCell" owner:nil options:nil];當我以某種方式設置rootviewcontroller而不是另一種方式時出現SIGABRT錯誤。讓我先從我WSCSessionTable示例代碼它繼承的UITableViewController:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"WSCSessionCell"; 

    WSCSessionCell *cell = (WSCSessionCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (cell == nil) { 

     NSArray * topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"WSCSessionCell" owner:nil options:nil]; 

     for(id currentObject in topLevelObjects) 
     { 
      if([currentObject isKindOfClass:[UITableView class]]) 
      { 
       cell = (WSCSessionCell *) currentObject; 
       break; 
      } 
     } 

    } 
return cell; 
} 

方案1 - 沒問題 - 沒有SIGABRT

上面的代碼工作正常,當我NavigationController rootviewcontrols WSCSessionTable。這是我的故事板看起來像參考。 Navigation Controller to WSCSessionTable

方案2 - 的問題,代碼使得SIGABRT

上面的代碼導致SIGABRT錯誤當我把一個UIViewController導航控制器和WSCSessionTable之間。然後我使用一個按鈕來實例化WSCSessionTable。這是我的故事板設立

Activate WSCSession via button tap

這是按鈕

- (IBAction)goToSession:(id)sender 
{ 
    wscAppDelegate *appDelegate = (wscAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]]; 
    wscSessions *childView = [storyboard instantiateViewControllerWithIdentifier:@"sessionstable"]; 
// wscSessions *childView = [storyboard instantiateViewControllerWithIdentifier:@"sessionstable"]; 
    childView._arrData = appDelegate._arrSession; 
    childView._arrSpeaker = appDelegate._arrSpeaker; 
    childView.title = @"SEssions"; 
    [self.navigationController pushViewController:childView animated:YES]; 
    } 

我在與一個NSBundle mainbundle行的cellForRowAtIndexPath功能得到了SIGABRT錯誤事件處理程序。下面是錯誤輸出

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/dduvernet/Library/Application Support/iPhone Simulator/5.1/Applications/54EF04FD-E010-48BB-A0F4-EB0F12BF8D6A/gmmiphone.app> (loaded)' with name 'WSCSessionCell'' 
*** First throw call stack: 
(0x1da1022 0x2359cd6 0x1d49a48 0x1d499b9 0xa98638 0xa99eb7 0x3d9f 0x911c54 0x9123ce 0x8fdcbd 0x90c6f1 0x8b5d21 0x1da2e42 0x181679 0x18b579 0x1104f7 0x1123f6 0x111ad0 0x1d7599e 0x1d0c640 0x1cd84c6 0x1cd7d84 0x1cd7c9b 0x28f07d8 0x28f088a 0x877626 0x2138 0x2095 0x1) 
terminate called throwing an exception(gdb) 

 有誰知道我可以通過按鈕選項卡實例WSCSessiontable下來?

相關問題 - 我認爲這可能是真正的問題,我遇到:問題的 Why does tableView dequeueReusableCellWithIdentifier:CellIdentifier return null?

+0

什麼是打印到調試器控制檯的完整錯誤信息? –

+0

@Adam - 我更新了錯誤輸出的問題。 – John

+0

WSCSessionCell.xib是否存在於項目中,是否是正確目標的一部分? –

回答

1

的是,你正在尋找一個UITableView,而不是一個UITableViewCell。

相關問題