1

In the following OS X application, how can I create a Dictionary in a similar way to how I create an NSDictionary?

I suppose I need to find a method on Dictionary that performs the same task as NSDictionary(contentsOfFile:infoPlist) but I am not sure what this Dictionary method is.

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?) {
    }
}

Many thanks in advance.

gepree
  • 617
  • 7
  • 9

1 Answers1

2

Sadly there is no way to do this in native swift dictionaries at the moment. However using NSDictionary is still quite fine.

For more info you can look at this similar question

Community
  • 1
  • 1
Astrogat
  • 1,617
  • 12
  • 24