当前位置: 首页 > news >正文

河南企业网站建设如何做好网络营销推广

河南企业网站建设,如何做好网络营销推广,哈尔滨网站制作费用,公众号如何做网站目录 集合类型 数组 ​编辑 合集 合集操作 字典 Where 集合类型 Swift提供了三种主要的集合类型:组合,合集,字典。 数组是有序的值的集合。 合集是唯一值的无序集合。 字典是无序的键值对集合。 数组 Swift数组的类型的完整写法是…

目录

集合类型

数组

​编辑

合集

合集操作

字典

Where


集合类型

Swift提供了三种主要的集合类型:组合,合集,字典。

数组是有序的值的集合。

合集是唯一值的无序集合。

字典是无序的键值对集合。

数组

Swift数组的类型的完整写法是 Array[Element]


import UIKitvar someInts=[Int]()
print("somInts is of type [Int] with \(someInts.count) items.")
someInts.append(1)
print("someInts is \(someInts)")//使用默认值创建数组
//Swift的Array类型提供了初始化器来创建确定大小且元素都设定为相同默认值的数组
var threeInts=Array(repeating: 2, count: 6)
print("threeInts is \(threeInts)")//把两个兼容类型的现存数组用加运算符(+)加在一起来创建一个新数组
var anotherThreeInts=Array(repeating: 6, count: 2)
var newInts=anotherThreeInts+threeInts
print("newInts is \(newInts)")var arrayList:[String]=["hello","world"]
print("arrayList is \(arrayList)")//得出数组中元素的数量
print("The arrayList contains \(arrayList.count) items")//通过布尔量 isEmpty属性来检查 count属性是否等于0
if arrayList.isEmpty {print("The arrayList is empty.")
} else {print("The arrayList is not empty.")
}//通过 append()方法给数组末尾添加新的元素
arrayList.append("wuo")
print("arrayList is \(arrayList)")//可以使用加赋值运算符 ( +=)来在数组末尾添加一个或者多个同类型元素
arrayList += ["hello","am"]
print("arrayList is \(arrayList)")//取值
var firstItem=arrayList[0]
print("arrayList first item \(firstItem)")
print("arrayList \(arrayList[1...4])")//把元素插入到特定的索引位置,调用数组的 insert(_:at:)方法
arrayList.insert("okok", at: 1)
print("arrayList is \(arrayList)")//使用 remove(at:)方法来移除一个元素
var removeFirst=arrayList.remove(at: 0)
print("removeFirst is \(removeFirst)")//如果你想要移除数组最后一个元素,使用 removeLast()方法而不是 remove(at:)方法以避免查询数组的 count属性//遍历
print("遍历数组")
for i in arrayList{print(i)
}//遍历数组中的每一个元素以及值的整数索引
//使用 enumerated()方法来遍历数组
//enumerated()方法返回数组中每一个元素的元组,包含了这个元素的索引和值
for (index,value) in arrayList.enumerated(){print("Item \(index+1) : \(value)")
}

合集

合集将同一类型且不重复的值无序地储存在一个集合当中。

Swift 的合集类型写做 Set<Element>。

合集操作

  • 使用 intersection(_:)方法来创建一个只包含两个合集共有值的新合集;
  • 使用 symmetricDifference(_:)方法来创建一个只包含两个合集各自有的非共有值的新合集;
  • 使用 union(_:)方法来创建一个包含两个合集所有值的新合集;
  • 使用 subtracting(_:)方法来创建一个两个合集当中不包含某个合集值的新合集。

字典

 Dictionary<Key, Value>,其中的 Key是用来作为字典键的值类型, Value就是字典为这些键储存的值的类型。

字典的简写形式为 [Key: Value]


var Ints=[Int:String]()
var fruit:[Int:String]=[1:"apple",2:"orange",3:"xigua"]
print("The fruit dictionary contains \(fruit.count) items")//isEmpty//添加
fruit[4]="hello"
print("The fruit dictionary contains \(fruit) items")fruit[4]="wuo"
print("The fruit dictionary contains \(fruit) items")//removeValue(forKey:)
if let removedValue = fruit.removeValue(forKey: 1) {print("The removed fruit's name is \(removedValue).")
} else {print("The fruit dictionary does not contain a value for 1.")
}
print("The fruit dictionary contains \(fruit) items")//遍历
for (index,value)in fruit{print("\(index) : \(value)")
}for i in fruit.keys{print("keys : \(i)")
}for i in fruit.values{print("value : \(i)")
}for i in fruit.keys.sorted(){print("有序的: \(i)")
}//用 keys或 values属性来初始化一个新数组
let fruitKeys = [Int](fruit.keys)
let fruitValues=[String](fruit.values)
print("fruitKeys are \(fruitKeys) \n fruitValues are \(fruitValues)")

Where

switch情况可以用Where分句来检查额外的情况。


import UIKitlet point=(1,-1)
switch point{
case let (x,y) where x==y:print("\(x),\(y) is on the line x==y")
case let (x,y) where x == -y:print("\(x),\(y) is on the line x==-y")
case let (x,y):print("\(x),\(y) is just some arbitary point.")
}

草稿箱里的这一篇博客被我忘了,虽然内容挺少的,大家先将就着看吧。

http://www.tj-hxxt.cn/news/122209.html

相关文章:

  • 用微信微博网站来做睡眠经济重庆人力资源和社会保障网
  • 黔西南州党风廉政建设网站app线下推广怎么做
  • 南昌做网站的公司哪个比较好的潍坊网站定制模板建站
  • 丝绸之路网站建设策划书太原网络营销公司
  • 网站开发使用api对seo世界搜索引擎大全
  • 苏州营销型网站建设方案小学生班级优化大师
  • 学做网站前景搜索广告是什么
  • 做网站的软件著作权神童预言新冠2023结束
  • 网站建设需求文案西安关键词排名提升
  • 微博网站模板 css十大推广app平台
  • 外贸免费建设网站制作淘宝指数在线查询
  • dedecms 古典棕色大气风格中药医药企业网站模板源码网络推广员一个月多少钱
  • 网站的站点地图怎么做百度app下载安装 官方
  • 蓝色网站建设国内最好的seo培训
  • https网站制作品牌策略的7种类型
  • wp网站如何做文件的付费下载网络推广网站建设
  • 公司怎么在百度做网站域名是什么 有什么用
  • ps如何做游戏模板下载网站如何提高自己在百度的排名
  • .net网站开发源码售卖链接
  • 做网站为什么不要源代码信息流广告投放公司
  • 国内做外贸如何访问外国网站黄页推广平台有哪些
  • 百度关键词优化排名合肥百度推广排名优化
  • 泉州网络公司都网站手机优化
  • 石家庄做网站的公司有哪些企业网站的搜索引擎推广与优化
  • 网站特殊字体谷歌广告推广网站
  • 贵阳查房子备案的网站优就业seo
  • 怎么做支付网站青岛seo关键字排名
  • 网络推广方法的分类长沙优化网站
  • 成都最新规划官方消息在线seo外链工具
  • 武汉光谷做网站的公司营销网站策划方案