【发布时间】:2014-10-02 06:03:04
【问题描述】:
我有一个问题。 我创建了一个页面视图控制器来展示我的应用程序的教程。此页面视图控制器显示在 应用程序的首次启动。我正在将以下代码添加到 AppDelegate.m 文件中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"])
{
//Normal flow
}
else
{
//To show the tutorial
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"HasLaunchedOnce"];
[[NSUserDefaults standardUserDefaults] synchronize];
TutorialViewController* tutorialViewController = [[TutorialViewController alloc] init];
[self.window setRootViewController:tutorialViewController];
}
return YES;
}
我的问题是在应用程序的第一次午餐时出现以下错误。
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“* -[__NSPlaceholderArray initWithObjects:count:]: 尝试从 objects[0] 插入 nil 对象” * 首先抛出调用栈:
有人可以帮我解决这个问题吗?
干杯。
【问题讨论】:
-
我猜问题不在
AppDelegate.m文件中。此错误表示您正在尝试使用 nil-reference 初始化NSArray对象。 -
添加一个所有异常断点,让我们知道应用程序崩溃时的行。
-
它在 [self.window setRootViewController:tutorialViewController] 行中崩溃;
标签: ios controller launch appdelegate