设为首页 加入收藏

TOP

Swift3 - String 字符串、Array 数组、Dictionary 字典的使用(三)
2017-10-10 12:15:07 】 浏览:8506
Tags:Swift3 String 字符串 Array 数组 Dictionary 字典 使用
nal": [91, 66, 45, 28, 15, 6, 1],
/// "primes": [15, 13, 11, 7, 5, 3, 2], /// "triangular": [28, 21, 15, 10, 6, 3, 1]] // 遍历字典 let imagePaths = ["star": "/glyphs/star.png", "portrait": "/images/content/portrait.jpg", "spacer": "/images/shared/spacer.gif"] for (key, value) in imagePaths { print("The path to '\(key)' is '\(value)'.") } /// search a dictionary's contents for a particular value // let glyphIndex = imagePaths.index { // $0.value.hasPrefix("/glyphs") // } // print(imagePaths[glyphIndex!].value)// /glyphs/star.png // print(imagePaths[glyphIndex!].key)// star let glyphIndex = imagePaths.contains { $0.value.hasPrefix("/glyphx") } print(glyphIndex)// ture /// Bridging Between Dictionary and NSDictionary // imagePaths as NSDictionary print("keys:\((imagePaths as NSDictionary).allKeys) ,values:\((imagePaths as NSDictionary).allValues)") }

 

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Swift3新特性汇总 下一篇swift 学习笔记[1]

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目