NSBundle mainBundle给出sigabrt错误? [英] NSBundle mainBundle gives sigabrt error?

查看:58
本文介绍了NSBundle mainBundle给出sigabrt错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用xCode 4.2来构建iPhone应用程序.

相关问题-我认为这可能是我遇到的真正问题:

解决方案

部分问题是您要搜索的是UITableView而不是UITableViewCell.

I am using xCode 4.2 to build an iPhone app.

Related Question - I think this might be the REAL problem I'm experiencing: Why does tableView dequeueReusableCellWithIdentifier:CellIdentifier return null?

But let me continue with this quesiton anyway:

There's something about the line [[NSBundle mainBundle] loadNibNamed:@"WSCSessionCell" owner:nil options:nil]; that gives me a SIGABRT error when I set up the rootviewcontroller in a certain way and not another way. Let me start with sample code from my WSCSessionTable which inherits 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;
}

Scenario 1 - No Problem - No SIGABRT

The code above works fine when my NavigationController rootviewcontrols WSCSessionTable. Here's what my storyboard looks like for reference.

Scenario 2 - Problems, Code causes SIGABRT

The above code causes a SIGABRT error when I put a UIViewController between the navigation controller and WSCSessionTable. I then use a button to instantiate WSCSessionTable. here's my story board set up

This is the event handler for the button

- (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]; 
    }

I get a sigabrt error in in the cellforrowatindexpath function on the line with the nsbundle mainbundle. Here's the error output

*** 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) 

 Does anyone know how I can instantiate WSCSessiontable via button tab down?

Related Question - I think this might be the REAL problem I'm experiencing: Why does tableView dequeueReusableCellWithIdentifier:CellIdentifier return null?

解决方案

Part of the issue is that you are searching for a UITableView instead of a UITableViewCell.

这篇关于NSBundle mainBundle给出sigabrt错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆