iOS Application Configuration File

后端 未结 8 1562
南笙
南笙 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:45

    Updated for Swift 3 Xcode 8

    Add a new property list to your project named "Sample.plist". Then see the following example.

        let path: String = Bundle.main.path(forResource: "Sample", ofType: "plist")!
        let sampleConf: NSDictionary = NSDictionary(contentsOfFile: path)!
        print(sampleConf.object(forKey: "test") as! String)
    

提交回复
热议问题