随笔分类 -  Swift

摘要:// // ViewController.swift // 18-Swift中的闭包 // // Created by apple on 15/11/27. // Copyright © 2015年 xiaomage. All rights reserved. // import UIKit cla 阅读全文
posted @ 2016-08-28 21:39 阿法狗的世界
摘要://: Playground - noun: a place where people can play import UIKit class Person : NSObject { var name : String? var age : Int = 0 // 父类的init方法,子类再来写的时候 阅读全文
posted @ 2016-08-28 21:37 阿法狗的世界
摘要://: Playground - noun: a place where people can play import UIKit // 1.没有参数,没有返回值的函数 func about() -> Void { print("iPhone6s Plus 玫瑰金") } about() // 没有 阅读全文
posted @ 2016-08-28 21:36 阿法狗的世界
摘要://: Playground - noun: a place where people can play import UIKit /******************** 内部参数和外部参数 ********************/ // 内部参数:只有在内部才可以看到对应的参数名称 // 外 阅读全文
posted @ 2016-08-28 21:35 阿法狗的世界
摘要://: Playground - noun: a place where people can play import UIKit class Person : NSObject { var name : String? { // 可以给newValue自定义名称 willSet (new){ // 阅读全文
posted @ 2016-08-28 21:34 阿法狗的世界
摘要://: Playground - noun: a place where people can play import UIKit class Student : NSObject { // 1.属性 // 1> 存储属性 // 注意一:在开发中,如果是对象或者结构体,在没有赋值的情况下通常定义为可 阅读全文
posted @ 2016-08-28 21:33 阿法狗的世界
摘要://: Playground - noun: a place where people can play import UIKit /************************** 字典定义 *****************************/ // Swift中字典的类型Dictio 阅读全文
posted @ 2016-08-28 21:31 阿法狗的世界
摘要:// 元祖也是一个数据集合,可以在集合中定义一组数据 // 元祖的定义使用:(元素1,元素2) ("1001", "张三", 19, 1.88) (id : "1001", name : "张三", age : 19, height : 1.88) // 用一个数据类型来描述网络请求错误 // er 阅读全文
posted @ 2016-08-28 21:31 阿法狗的世界
摘要://: Playground - noun: a place where people can play import UIKit /************************** 字典定义 *****************************/ // Swift中字典的类型Dictio 阅读全文
posted @ 2016-08-28 21:30 阿法狗的世界
摘要:/********************** 数组定义 **************************/ // 数组:Array表示数据 // let修饰的标识符是不可变数组(元素确定后不能修改) // var修饰的标识符是可变数组(可以添加和删除元素) // 注意: // 1>定义数组是使 阅读全文
posted @ 2016-08-28 21:29 阿法狗的世界
摘要:// 定义字符串 let string = "Hello World" let string1 : String string1 = "Hello" // 字符串的遍历 for c in string1.characters { print(c) } // 字符串的拼接 // 1.两个字符串之间的拼 阅读全文
posted @ 2016-08-28 21:28 阿法狗的世界
摘要:// for循环 // for循环后面不跟() // for循环的第一种写法 for var i = 0; i < 10;i++ { print(i) } // OC中的forin写法 let array = ["why", "lnj", "lmj", "yz"] for str in array 阅读全文
posted @ 2016-08-28 21:27 阿法狗的世界
摘要:import UIKit // 整型:Int 浮点型:Double let π : Double = 3.14 var age : Int = 22 // 注意: // 1.如果一个标识符在定义时有直接复制,那么系统会根据后面赋值的类型来决定前面标识符的类型,这时(:类型)可以省略 // 2.查看标 阅读全文
posted @ 2016-08-28 21:25 阿法狗的世界
摘要:// 1.变量和常量的基本用法 // 1> 使用let定义变量 // 2> 使用var定义常量 let age : Int = 20 // age = 22 var height : Double = 1.78 height = 1.88 // 2.使用注意: // 1> 指向的对象不可以修改(指针 阅读全文
posted @ 2016-08-28 21:23 阿法狗的世界
摘要:func log<T>(message:T,file: String=__FILE__, funcName: String=__FUNCTION__, linNum:Int=__LINE__){ let fileName=(file as NSString).lastPathComponent pr 阅读全文
posted @ 2016-08-28 16:15 阿法狗的世界