Swift
文章平均质量分 62
普通网友
这个作者很懒,什么都没留下…
展开
-
Swift 1
//print("Hello, World!") //类型安全 //定义常量(oc的常量前const表示修饰符只读) //let 定义常量 var定义变量 let str="hello world!" //Int Double Float Bool String Set Array Dictionary //元祖 可选 //显示申明 let score1: Int = 10原创 2016-05-05 15:33:48 · 200 阅读 · 0 评论 -
Swift 2
//1.常量和变量 //a. 用var来定义一个变量 ,let定义一个常量 常量一旦设定就不可以更改,变量可以更改 //编译器可以自动推断类型 var mayVarible = 43 mayVarible = 78 print(mayVarible) let myCount = 76 //b. 可以用任意字符作为常量 变量名包括Unicode字符串 不能以数字开头,不能使用数原创 2016-05-05 15:44:29 · 150 阅读 · 0 评论 -
Swift3
/* 数组:有序的数据集 集:无序且无重复的数据集 字典:无序且无重复的键值对的集 */ //集合的可变性,集合类型的数据一旦设定为不可变(let)就不能对值进行修改,反之(var)就可以 //数组 var inlist = [1,2,4,6] print(inlist) let stringList = ["A","B","C"] print(stringLis原创 2016-05-05 16:04:55 · 223 阅读 · 0 评论 -
Swift4
//1.定义一个类和结构体 //定义一个结构体 struct Resolution { var width = 0 var height = 0 } //定义一个类 class ViewMode { var resolution = Resolution() var name: String? var frameRate = 0.0 var interlace = fal原创 2016-05-05 16:06:22 · 284 阅读 · 0 评论 -
Swift5
//定义协议 protocol SomeprotocolOne{ func printSomething() } protocol SomeprotocolTwo{ } class SomeClass{ } //采纳协议 class SomeClassOne:SomeClass,SomeprotocolOne,SomeprotocolTwo{ func printS原创 2016-05-05 16:07:52 · 383 阅读 · 0 评论 -
Swift UI
class ViewController: UIViewController { var label : UILabel? var textField : UITextField? override func viewDidLoad() { super.viewDidLoad() label = UILabel(frame: CGRect(x: 0, y: 0, width: 300原创 2016-05-05 16:09:05 · 268 阅读 · 0 评论