如何调用具有多个参数的bool类型函数objective c

时间:2013-05-06 06:42:29

标签: iphone objective-c

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"])
    {
        // app already launched
        return NO;
    }
    else
    {
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"HasLaunchedOnce"];
        [[NSUserDefaults standardUserDefaults] synchronize];
        // This is the first launch ever
        return  YES;
    }
}

我如何在它所在的同一个类的另一个方法中调用此函数。

2 个答案:

答案 0 :(得分:3)

这是一种委托方法,你从不明确地称之为

应用程序完成启动后立即调用。

答案 1 :(得分:1)

NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];

// to access the value of HasLaunchedOnce, write:
[preferences valueForKey:@"HasLaunchedOnce"]; 

// to set the value of HasLaunchedOnce, write:
[preferences setValue:TRUE forKey:@"HasLaunchedOnce"];

您可以在应用中的任何位置使用此功能。