ios - get data from combination of dictionary and array from plist in swift 2.2 -


i hava plist file configuration this.

its root dictionary has 3 item, item1,item2,item3

item 3 array.

when values of root_dict, item3 returns value array.

item3 has item (item4) dictionary. item 4 has item(item5)

i want value of item5

root_dict      item1 --- string     item2 --- dict     item3 --- array         |         ------ item 4 ---- dic                  |                  -------------item5----array 

i using below code:

    var mydict: nsdictionary?       if let path = nsbundle.mainbundle().pathforresource("info", oftype: "plist") {         mydict = nsdictionary(contentsoffile: path) //mydict has 3 item     }      var dicdata = mydict!["item3"] as! dictionary<string, anyobject>      (key, value) in dicdata{          print(key)     } 

its not working.

any kind of highly appreciated.

i totally agree @nirav follow might work you.

    var mydict: nsdictionary?           if let path = nsbundle.mainbundle().pathforresource("fetchdata", oftype: "plist") {             mydict = nsdictionary(contentsoffile: path) //mydict has 3 item         }          var dicdata = mydict!["item3"] as! nsarray         print(dicdata.valueforkey("item5"))            

your console output should ( ( //here data ) )


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -