make an array of dictionary in plist swift -
i trying create plist this... using code objective-c translated swift... unfortunately array empty remains
what wrong? in advance!
<plist version="1.0"> <array> <dict> <key>uscita_ore</key> <string>18</string> </dict> <dict> <key>uscita_ore</key> <string>17</string> </dict> </array> </plist> var paths = nssearchpathfordirectoriesindomains(nssearchpathdirectory.documentdirectory, nssearchpathdomainmask.userdomainmask, true) nsarray var documentsdirectory:anyobject = paths[0] var path = documentsdirectory.stringbyappendingpathcomponent("orari_marcate.plist") var filemanager = nsfilemanager.defaultmanager() var fileexists:bool = filemanager.fileexistsatpath(path) var lista_marcate : nsmutabledictionary? var marcate2 :nsmutablearray? if fileexists == false { marcate2 = nsmutablearray (capacity: 0) } else { marcate2 = nsmutablearray(contentsoffile: path) } lista_marcate?.setvalue("\(campo_ora_fine.text)", forkey: "campo_ora_fine") lista_marcate?.setvalue("\(campo_min_fine.text)", forkey: "campo_min_fine") lista_marcate?.setvalue("\(fine_ora)", forkey: "fine_ora") lista_marcate?.setvalue("\(fine_min)", forkey: "fine_min") marcate2?.addobject(lista_marcate!) marcate2?.writetofile(path, atomically: true) println(path)
Comments
Post a Comment