NSArrayM insertObject:atIndex:]:object不能为nil' [英] NSArrayM insertObject:atIndex:]: object cannot be nil'
问题描述
经过大量搜索,并尝试使用stackoverflow上的一些解决方案,我没有找到任何可以解决我的错误的答案:
我有一个UIViewcontroller,谁的名字是WorldViewController。在这个UIViewcontroller中,我有一些UIViews。我想从一些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 ?
编辑:我的viewcontroller的init方法
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:]:object不能为nil'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!