经过大量搜索,并尝试在 stackoverflow 上使用一些解决方案,我没有找到任何可以解决我的错误的答案:我有一个 UIViewcontroller,他的名字是 WorldViewController。在这个 UIViewcontroller 中,我初始化了一些 UIViews。我想从一些 UIView 中修改一些依赖于 WorldViewController 的变量。现在我把这些线:
WorldViewController * World = [[WorldViewController alloc] init];
它给了我:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
那么,如何解决呢?它可能来自 WorldViewController 正在运行的事实吗?那么,如何解决呢?
编辑:我的视图控制器的 init 方法
- (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;
}
谢谢 !