gpt4 book ai didi

ios - NSArrayM 插入对象 :atIndex:]: object cannot be nil'

转载 作者:可可西里 更新时间:2023-11-01 06:17:45 64 4
gpt4 key购买 nike

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

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

它给了我:

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

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

编辑:我的 View Controller 的初始化方法

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

谢谢!

最佳答案

我遇到了类似的问题。我的错误是没有将我试图加载的 View 标记为初始 View Controller 。我的猜测是没有初始 View Controller 可以添加到数组中,因此该对象为零。我不确定这对回答您的问题有多好,但它对我有用。

enter image description here

关于ios - NSArrayM 插入对象 :atIndex:]: object cannot be nil',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17031736/

64 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com