-1

Firstly, I have found loads covering this issue on StackOverflow but it is all ObjectiveC and not Swift.

Can anyone provide a link, or share some code to explain how to extract annotations information from a plist?

My Plist is...

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <dict>
        <key>name</key>
        <string>London Eye</string>
        <key>location</key>
        <string>{51.503324,-0.119543}</string>
    </dict>
    <dict>
        <key>name</key>
        <string>Big Ben</string>
        <key>location</key>
        <string>{51.500729,-0.124625}</string>
    </dict>
</array>
</plist>

Using Map Kit, XCOde and Swift.

So far my View Controller just contains code to obtain the users position and allow the user to add custom annotation

Many thanks in advance

metheone
  • 15
  • 3

1 Answers1

1

for load file plist

var dict: NSDictionary = NSDictionary()

// load file to dict

if let path = NSBundle.mainBundle().pathForResource("Name_file", ofType: "plist") {

    dict = NSDictionary(contentsOfFile: path)

}

var array = dict["array"] as! NSMutableArray

for item in array {

  if let dic = item as? NSDictionary {
      print(dic["key"] as! String)
  }

}
ZAV
  • 371
  • 4
  • 12