I want to write a test that says if this is the first time the app is being launched, then directions should be displayed. How can i detect the first app launch with Frank? I was thinking use NSUserDefaults, but I still don't know how to do that. Example step definition code would be great. Thanks a lot.
Asked
Active
Viewed 123 times
1 Answers
2
Take advantage of the fact that an NSUserDefaults
not previously set is nil:
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSNumber *firstRun = [userDefaults valueForKey:@"firstRun"];
if (firstRun == nil)
{
[userDefaults setValue:@YES forKey:@"firstRun"];
[userDefaults synchronize];
// Do what you want here
}

Richard Brown
- 11,346
- 4
- 32
- 43
-
Right but frank step definitions are in ruby. My question is: How do you check this from within a frank step definition? – pachun Mar 03 '13 at 18:46