[__NSArrayM insertObject:atIndex:]: object cannot be nil

只愿长相守 提交于 2019-12-25 01:46:03

问题


For some reason that I cannot find I am getting the following error:

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

As I am quite new in xCode i'd like some help. The application crashes in the following line:

[self.window makeKeyAndVisible];

in the ASAppDelegate.m file.

The whole function is like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.

AS_MainViewController *MyrootViewController = [[AS_MainViewController alloc]
                        initWithNibName:@"AS_MainViewController" bundle: [NSBundle mainBundle]];

self.window.rootViewController = MyrootViewController;

self.window.backgroundColor = [UIColor whiteColor];

return YES;
}

Could you please help me?

Thank you.


回答1:


finally the error has been resolved. I started a new empty project and did all the work from the beginning. As I was also copy-pasting from the old one, step by step I was also running each time in every step. The application run without problems. I finished it and now it runs. I could ever understand why and what this error was, but in a new project (having the same code with the old one) the problem does not exist!

Anyway, thank you for your help.



来源:https://stackoverflow.com/questions/15812899/nsarraym-insertobjectatindex-object-cannot-be-nil

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!