遍历字典

let dataSourcePath = Bundle.main.path(forResource:"movies",

                                              ofType:"plist")

let datasourceDictionary = NSDictionary(contentsOfFile: dataSourcePath!)

for (key,value) in datasourceDictionary! {

            let name = key as? String

            let url = URL(string:value as? String?? "")

            if name !=nil &&  url !=nil {

                let movieRecord = MovieRecord(name:name!, url:url!)

                self.movies.append(movieRecord)

            }

  }

你可能感兴趣的:(遍历字典)