swift学习笔记_iOS开发(一)
来源:互联网 发布:一元云购源码 犯法吗 编辑:程序博客网 时间:2024/06/05 15:58
swift已经问世n久了,给自己充充电,学习一下苹果的新东西,苹果公司日渐推崇更为简洁明了更为直观快速的程序开发模式,从适配的AutoLayout到Swift语言,苹果一直在鼓励开发者去探索使用新技术,而作为一个程序员,一定是要走在技术的最前沿,只有掌握了第一手资料才能更好的适应和雄起。
//打印 print("Hello world and how are you") //定义常量和变量 let常量 var变量 let a=3 print(a) var t=2 print(t) t=4 print(t) //在string中加入数值 //用法一: let label="hello" let width=2 let labeltime=label + String(width) print(labeltime) //用法二: let appleNumber=3 let orangeNumber=5 let appleSummary="appleSummary is \(appleNumber)" let fruitSummary="fruitSummary is \(appleNumber + orangeNumber)" print(appleSummary) print(fruitSummary) //定义数组 var shoppingList=["catfish","water","tulips","blue paint"] print(shoppingList) //通过index改变其中的元素 shoppingList[2]="bottle of water" print(shoppingList) //通过key改变其中元素 var occupations = ["Malcolm":"Captain", "Kaylee":"Mechanic"] print(occupations) occupations["Jayne"]="Public Relations" print(occupations) occupations["Malcolm"]="Leader" print(occupations) //用初始化的方法 //定义空的数组 let emptyArray=[String]() //定义空的字典 let emptyDictionary=[String : Float]() //如果他们的数据类型在在之前已经确定,那么就可以用一下方法写空 shoppingList=[] occupations=[:] //另:数组和字典的区别-数组只需要把数据放进去就行,而字典需要key做索引 //用if,switch写条件判断语句;用for-in,for,while和repeat-while来写循环语句 let individualScores=[77,39,82,44,63] var teamScore=0 for score in individualScores{ if score > 50{ teamScore += 3 } else{ teamScore += 1 } } //在if语句中条件必须是布尔型的否则会报错这 if teamScore{ //报错:int 不是 Boolean Type //。。。 } //
1 0
- swift学习笔记_iOS开发(一)
- swift学习笔记_iOS开发(二)
- Swift开发iOS App学习笔记(一)---AppIcon & LaunchScreen
- Swift学习笔记(一)
- 学习Swift笔记 (一)
- swift学习笔记(一)
- 【iOS知识学习】_iOS入门知识学习(一)
- Swift学习笔记一
- swift学习笔记(一)
- Swift学习笔记(一)
- swift 学习笔记一
- swift学习笔记一
- swift学习笔记一
- Swift学习笔记(一)
- swift 学习笔记一
- Swift学习笔记一
- Swift 学习笔记(一)
- Swift学习笔记一(基础部分)
- cocos2d-x 3.x box2d显示debugDraw
- 关机后数据库启动错误
- JVM调优总结
- CoreData(1)
- [转][VC++]限制CEdit(Edit Contrl)只能输入数字和小数点
- swift学习笔记_iOS开发(一)
- 10001---Hibernate 概述
- iOS地图分析
- Linux fork函数
- 从校园到工作的路(六)——关于阅读源码的方法
- [转]MFC - 从屏幕右下角升起的弹窗
- 联调接口时的一些感悟
- Week1-6Background
- 进程间数据通信方式及特点