开发者

Show NSAlert on specific launches

开发者 https://www.devze.com 2023-02-12 04:53 出处:网络
I need to show an NSAlert on the 3rd, 10th and 20th launch of the app, so far I have tried: /* Note that the kLaunchCount is incremented as 开发者_如何学Goa Number in a dictionary */

I need to show an NSAlert on the 3rd, 10th and 20th launch of the app, so far I have tried:

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

The above code shows the NSAlert every launch.


That code parses as ...||2||3, which will always return true (since anything || 2 is true). You should put the launch count into a variable n and then use n == 3 || n == 10 || n == 20 as the test.

0

精彩评论

暂无评论...
验证码 换一张
取 消