0

我需要NSAlert在应用程序的第 3 次、第 10 次和第 20 次启动时显示一个,到目前为止我已经尝试过:

/* Note that the kLaunchCount is incremented as a Number in a dictionary */
if([[[NSUserDefaults standardUserDefaults] objectForKey:@"kLaunchCount"] intValue] == 1||2||3)
{
    /* show the NSAlert */
}

上面的代码显示了NSAlert每次启动。

4

1 回答 1

1

该代码解析为...||2||3,它将始终返回 true (因为任何事情|| 2都是真实的)。您应该将启动计数放入变量中n,然后n == 3 || n == 10 || n == 20用作测试。

于 2011-02-19T03:38:23.700 回答