How to read from a plist with Swift 3 iOS app

前端 未结 7 1890
無奈伤痛
無奈伤痛 2020-12-24 06:49

-Disclaimer-
I\'m extremely new to iOS and Swift development, but I\'m not particularly new to programming.

I have a basic iOS applicati

7条回答
  •  萌比男神i
    2020-12-24 07:06

    For Swift 3.0, Following code directly targeting to key. Where as dict object will give everything which will be there in your plist file.

    if let path = Bundle.main.path(forResource: "YourPlistFile", ofType: "plist"), let dict = NSDictionary(contentsOfFile: path) as? [String: AnyObject] {
                let value = dict["KeyInYourPlistFile"] as! String
        }
    

提交回复
热议问题