iOS Application Configuration File

后端 未结 8 1480
南笙
南笙 2021-01-31 16:13

In a C# application I always used an app.config file to save some data for my application to load when needed (e.g Connection String).

Wha

8条回答
  •  失恋的感觉
    2021-01-31 16:55

    For small bits of data like a connection string, I'd use NSUserDefaults.

    When you want to save your connection string, you'd do this:

    [[NSUserDefaults standardUserDefaults] setObject:myConnectionString 
                                              forKey:@"connectionString"];
    

    When you want to load it, you'd do this:

    myConnectionString = [[NSUserDefaults standardUserDefaults] 
                              stringForKey:@"connectionString"];
    

提交回复
热议问题