NSArrayM insertObject:atIndex:]: 对象不能为 nil' [英] NSArrayM insertObject:atIndex:]: object cannot be nil'

查看:27
本文介绍了NSArrayM insertObject:atIndex:]: 对象不能为 nil'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过大量搜索,并在stackoverflow上尝试了一些解决方案,我没有找到任何可以解决我的错误的答案:我有一个 UIViewController,他的名字是 WorldViewController.在这个 UIViewcontroller 中,我初始化了一些 UIView.我想从一些 UIViews 修改一些取决于 WorldViewController 的变量.现在我把这些行:

After a lot of search, and tries with some solutions on stackoverflow, i didn't find any answer which could solve my error : I have a UIViewcontroller, who's name is WorldViewController. In this UIViewcontroller, i had init some UIViews. I want to modificate some variables which depends of WorldViewController from some UIViews. And now that i put those lines :

WorldViewController * World = [[WorldViewController alloc] init];

它给了我:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'

那么,如何解决?可能是因为 WorldViewController 正在运行吗?那么,如何修复它?

So, how to fix it ? Could it comes from the fact that WorldViewController is running ? And so, how to fix it ?

我的视图控制器的初始化方法

Edit : init method of my viewcontroller

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization

        World1 = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 480.0)];
        [World1 setBackgroundColor:[UIColor blackColor]];
        [self.view addSubview:World1];
        [World1 release];

        [self.view addSubview:ViewPig];
        [self.view addSubview:level1view];
        [self.view addSubview:level2view];
        [self.view addSubview:LoadView];
        [LoadView AnimPigLoadingWith:PigChargement];
        [LoadView AppearLabelLoading];
        [self.view addSubview:FondPauseGrise];
        [self.view addSubview:FondPause];
        [self.view addSubview:BoutonResume];
        [self.view addSubview:BoutonHome];
        [self performSelector:@selector(Chargement) withObject:nil afterDelay:0.5];
        [self performSelector:@selector(ViewAppears) withObject:nil afterDelay:5.5+2.5];
        [self performSelector:@selector(LabelPrevientDepartWithImage:) withObject:Trois afterDelay:9];
        [self performSelector:@selector(LabelPrevientDepartWithImage:) withObject:Deux afterDelay:10];
        [self performSelector:@selector(LabelPrevientDepartWithImage:) withObject:Un afterDelay:11];
        [self performSelector:@selector(LabelPrevientDepartWithImage:) withObject:Go afterDelay:12];
        [self performSelector:@selector(Lancement) withObject:nil afterDelay:(3)];
        [self performSelector:@selector(GestionMaps) withObject:nil afterDelay:(11+2)];
    }
    return self;
}

谢谢!

推荐答案

您在问题中没有列出足够的代码来明确显示您在哪里犯了错误.

You haven't listed enough code in your question to definitely show where you're making an error.

在您的代码中查找任何显示insertObject:atIndex:"的行.您插入的对象显然为零.

Look in your code for any lines that say "insertObject:atIndex:". The object you're inserting is apparently nil.

如果找不到这一行,在符号"[NSArray insertObject:atIndex:]上添加一个符号断点"(单击链接查看与您的问题密切相关的答案中的具体说明),看看您是否可以在崩溃发生之前立即中断.

If you can't find this line, add a symbolic breakpoint on the symbol "[NSArray insertObject:atIndex:]" (click the link to see specific instructions in an answer of a closely related question to yours) and see if you can break on it right before the crash happens.

这篇关于NSArrayM insertObject:atIndex:]: 对象不能为 nil'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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