【问题标题】:Show NSAlert on specific launches在特定发布时显示 NSAlert
【发布时间】:2011-02-19 03:35:41
【问题描述】:

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

/* 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

【问题讨论】:

    标签: cocoa compare nsalert


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2012-01-19
      • 1970-01-01
      • 1970-01-01
      • 2015-07-31
      • 1970-01-01
      • 1970-01-01
      • 2012-09-23
      • 2017-12-08
      • 1970-01-01
      相关资源
      最近更新 更多