- https://developer.apple.com/cn/documentation/swiftui/
- https://developer.apple.com/tutorials/swiftui
Link
- Open-Source iOS Apps
- iPhone手机-模拟定位(钉钉打卡)
- iPhone模拟定位(非越狱修改手机定位)
- 拖入图片实现
- https://www.jianshu.com/p/53274bee4a64
- https://download.csdn.net/blog/column/9909866/133410368
- https://blog.csdn.net/iCloudEnd/article/details/112859438
- https://blog.csdn.net/iCloudEnd/article/details/113620445
常量和变量
声明
var a = 1
let b = 2
// 指定类型
var c: Int = 1
// 同时声明多个变量
var d, e, f: String = 'g'
数据类型
Int
Int.max
Int.min
UInt.max
UInt.min = 0
Int8
Int16
...
// 声明一个二进制、八进制、十六进制
let binaryInt: Int = 0b10001
let octalInt: Int = 0o21
let hexInt: Int = 0x11
//
let bigNum = 1_000_000
Float、Double
let a = 1.25e10
let b = 1.25e-8
let bigFloat = 1_000.000_000_1
// CGFloat
UIColor()
Boolean
不能直接使用非0值判断
Tuple(结构体)
// 可以存储多个不同数据类型
let foo = ( 1, "bar")
// 指定类型
let foo: ( Int, Int, Int) = ( 1, 2, 3 )
// 指定key
let foo = ( x: 3, y: 4 )
let foo: ( x: Int, y: Int) = ( 3, 4 )
// 如何使用?
let ( x, y ) = foo
foo.0
foo.1
// 使用下划线忽略值
let ( x, _ ) = foo
String 双引号
可以使用中文命名变量
print( 1, 2, 3 )
print( 1, 2, 3, separator: ', ', terminator: ".\n")
// 字符串插值
print( "\(x) * \(y) = \(x*y)" )
运算符
赋值运算符
不返回值
数学运算符
除法 可能需要类型转换
比较运算符
逻辑运算符
三目运算符
变量初始化 let
区间运算符
a...b
a..<b
for i in 1...10{
i // i 常量
}
高级运算符 ?
逻辑控制
- 顺序结构
- 循环结构
- 选择结构
for ... in
for _ in arr{}
for循环
var i = 0
for ; i < 10 ; {
i++
}
for var i = -1 ; i < 9 ; i += 0.5{
// ...
}
while
repeat ... while
continue break
if
switch
不需要 break,可以用 逗号 所有可能性,不然要加default,空语句使用 () 或 break fallthrough