在下面的OS X应用程序中,如何以与创建NSDictionary类似的方式创建Dictionary?
我想我需要在Dictionary上找到一个与NSDictionary(contentsOfFile:infoPlist)执行相同任务的方法,但我不确定这个Dictionary方法是什么。
import Cocoa
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
func applicationDidFinishLaunching(aNotification: NSNotification?) {
var infoPlist = "/Applications/Calendar.app/Contents/Info.plist"
var nsDictionary = NSDictionary(contentsOfFile:infoPlist)
println("nsDictionary = \(nsDictionary)")
var dictionary = Dictionary<String, String>()
// TODO: How do I add entries from "infoPlist" to "dictionary"
// like I do above with the old "nsDictionary"?
println("dictionary = \(dictionary)")
}
func applicationWillTerminate(aNotification: NSNotification?) {
}
}
非常感谢提前。