├── Swift知识点 ├── Swift关键字 │ ├── README.md │ ├── 柯里化1 │ │ ├── 柯里化1 │ │ │ ├── Assets.xcassets │ │ │ │ ├── Contents.json │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ └── Contents.json │ │ │ ├── ViewController.swift │ │ │ ├── test.swift │ │ │ ├── AppDelegate.swift │ │ │ ├── Base.lproj │ │ │ │ ├── Main.storyboard │ │ │ │ └── LaunchScreen.storyboard │ │ │ ├── Info.plist │ │ │ └── SceneDelegate.swift │ │ ├── 柯里化1Tests │ │ │ ├── Info.plist │ │ │ └── ___1Tests.swift │ │ └── 柯里化1UITests │ │ │ ├── Info.plist │ │ │ └── ___1UITests.swift │ ├── 可选项 │ │ └── 可选项 │ │ │ └── main.swift │ ├── Any │ │ └── Any │ │ │ └── main.swift │ ├── 默认参数 │ │ └── 默认参数 │ │ │ └── main.swift │ ├── Tuple │ │ └── Tuple │ │ │ └── main.swift │ ├── 柯里化 │ │ └── 柯里化 │ │ │ └── main.swift │ ├── lazy │ │ └── lazy │ │ │ └── main.swift │ ├── Mutating │ │ └── Mutating │ │ │ └── main.swift │ ├── autoclosure │ │ └── autoclosure │ │ │ └── main.swift │ ├── 尾递归 │ │ ├── 尾递归 │ │ │ └── main.swift │ │ └── 尾递归.xcodeproj │ │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── 尾递归.xcscheme │ ├── 下标 │ │ └── 下标 │ │ │ └── main.swift │ ├── 动态运行 │ │ └── 动态运行 │ │ │ └── main.swift │ ├── 属性观察器 │ │ └── 属性观察器 │ │ │ └── main.swift │ ├── associatedtype │ │ └── associatedtype │ │ │ └── main.swift │ ├── 反射 │ │ └── 反射 │ │ │ └── main.swift │ ├── Optional │ │ └── Optional │ │ │ └── main.swift │ ├── Sequence │ │ └── Sequence │ │ │ └── main.swift │ └── 操作符 │ │ └── 操作符 │ │ └── main.swift ├── OC到Swift │ ├── KVO │ │ ├── KVO │ │ │ ├── Assets.xcassets │ │ │ │ ├── Contents.json │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ └── Contents.json │ │ │ ├── AppDelegate.swift │ │ │ ├── Base.lproj │ │ │ │ ├── Main.storyboard │ │ │ │ └── LaunchScreen.storyboard │ │ │ ├── Info.plist │ │ │ ├── ViewController.swift │ │ │ └── SceneDelegate.swift │ │ ├── KVOTests │ │ │ ├── Info.plist │ │ │ └── KVOTests.swift │ │ └── KVOUITests │ │ │ ├── Info.plist │ │ │ └── KVOUITests.swift │ ├── Lock │ │ ├── Lock │ │ │ ├── Assets.xcassets │ │ │ │ ├── Contents.json │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ └── Contents.json │ │ │ ├── Lock-Bridging-Header.h │ │ │ ├── OCViewController.h │ │ │ ├── ViewController.swift │ │ │ ├── OCViewController.m │ │ │ ├── AppDelegate.swift │ │ │ ├── Base.lproj │ │ │ │ ├── Main.storyboard │ │ │ │ └── LaunchScreen.storyboard │ │ │ ├── Info.plist │ │ │ └── SceneDelegate.swift │ │ ├── LockTests │ │ │ ├── Info.plist │ │ │ └── LockTests.swift │ │ └── LockUITests │ │ │ ├── Info.plist │ │ │ └── LockUITests.swift │ ├── Option │ │ ├── Option │ │ │ ├── Assets.xcassets │ │ │ │ ├── Contents.json │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ └── Contents.json │ │ │ ├── Option-Bridging-Header.h │ │ │ ├── OCViewController.h │ │ │ ├── OCViewController.m │ │ │ ├── ViewController.swift │ │ │ ├── AppDelegate.swift │ │ │ ├── Base.lproj │ │ │ │ ├── Main.storyboard │ │ │ │ └── LaunchScreen.storyboard │ │ │ ├── Info.plist │ │ │ └── SceneDelegate.swift │ │ ├── OptionTests │ │ │ ├── Info.plist │ │ │ └── OptionTests.swift │ │ └── OptionUITests │ │ │ ├── Info.plist │ │ │ └── OptionUITests.swift │ ├── 关联对象 │ │ ├── 关联对象 │ │ │ ├── Assets.xcassets │ │ │ │ ├── Contents.json │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ └── Contents.json │ │ │ ├── 关联对象-Bridging-Header.h │ │ │ ├── OCViewController.h │ │ │ ├── ViewController.swift │ │ │ ├── OCViewController.m │ │ │ ├── AppDelegate.swift │ │ │ ├── Base.lproj │ │ │ │ ├── Main.storyboard │ │ │ │ └── LaunchScreen.storyboard │ │ │ ├── Info.plist │ │ │ └── SceneDelegate.swift │ │ ├── 关联对象Tests │ │ │ ├── Info.plist │ │ │ └── ____Tests.swift │ │ └── 关联对象UITests │ │ │ ├── Info.plist │ │ │ └── ____UITests.swift │ ├── 局部scope │ │ ├── 局部scope │ │ │ ├── Assets.xcassets │ │ │ │ ├── Contents.json │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ └── Contents.json │ │ │ ├── 局部scope-Bridging-Header.h │ │ │ ├── OCViewController.h │ │ │ ├── OCViewController.m │ │ │ ├── AppDelegate.swift │ │ │ ├── Base.lproj │ │ │ │ ├── Main.storyboard │ │ │ │ └── LaunchScreen.storyboard │ │ │ ├── ViewController.swift │ │ │ ├── Info.plist │ │ │ └── SceneDelegate.swift │ │ ├── 局部scopeTests │ │ │ ├── Info.plist │ │ │ └── __scopeTests.swift │ │ └── 局部scopeUITests │ │ │ ├── Info.plist │ │ │ └── __scopeUITests.swift │ ├── @UIApplicationMain │ │ ├── test │ │ │ ├── test │ │ │ │ ├── Assets.xcassets │ │ │ │ │ ├── Contents.json │ │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ │ └── Contents.json │ │ │ │ ├── ViewController.h │ │ │ │ ├── AppDelegate.h │ │ │ │ ├── SceneDelegate.h │ │ │ │ ├── ViewController.m │ │ │ │ ├── main.m │ │ │ │ ├── AppDelegate.m │ │ │ │ ├── Base.lproj │ │ │ │ │ ├── Main.storyboard │ │ │ │ │ └── LaunchScreen.storyboard │ │ │ │ ├── Info.plist │ │ │ │ └── SceneDelegate.m │ │ │ ├── testTests │ │ │ │ ├── Info.plist │ │ │ │ └── testTests.m │ │ │ └── testUITests │ │ │ │ ├── Info.plist │ │ │ │ └── testUITests.m │ │ └── test1 │ │ │ ├── test1 │ │ │ ├── Assets.xcassets │ │ │ │ ├── Contents.json │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ └── Contents.json │ │ │ ├── MyApplication.swift │ │ │ ├── ViewController.swift │ │ │ ├── main.swift │ │ │ ├── AppDelegate.swift │ │ │ ├── Base.lproj │ │ │ │ ├── LaunchScreen.storyboard │ │ │ │ └── Main.storyboard │ │ │ ├── Info.plist │ │ │ └── SceneDelegate.swift │ │ │ ├── test1Tests │ │ │ ├── Info.plist │ │ │ └── test1Tests.swift │ │ │ └── test1UITests │ │ │ ├── Info.plist │ │ │ └── test1UITests.swift │ ├── 自省 │ │ └── 自省 │ │ │ └── main.swift │ ├── GCD │ │ └── GCD │ │ │ ├── main.swift │ │ │ └── GCDTool.swift │ ├── 指针 │ │ └── 指针 │ │ │ └── main.swift │ ├── 实例化方法动态调用 │ │ └── 实例化方法动态调用 │ │ │ └── main.swift │ ├── 值类型和引用类型 │ │ └── 值类型和引用类型 │ │ │ └── main.swift │ ├── 条件编译 │ │ └── 条件编译 │ │ │ └── main.swift │ └── 协议 │ │ └── 协议 │ │ └── main.swift └── 函数式swift │ ├── 函数式思想 │ └── 函数式思想 │ │ └── main.swift │ ├── 数学函数 │ └── 数学函数 │ │ └── main.swift │ └── Map&Filter&Reduce │ └── Map&Filter&Reduce │ └── main.swift ├── GIF ├── entry.png ├── 下拉列表.gif ├── 倒计时.gif ├── UIButton扩展.png ├── UILabel扩展.gif ├── UITextView.gif └── UITextField.gif ├── SwifterProject ├── SwifterProject │ ├── Assets.xcassets │ │ ├── Contents.json │ │ ├── Order.imageset │ │ │ ├── Order@2x.png │ │ │ └── Contents.json │ │ ├── home.imageset │ │ │ ├── home@2x.png │ │ │ └── Contents.json │ │ ├── AccentColor.colorset │ │ │ └── Contents.json │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Service.plist │ ├── Module.plist │ ├── BaseNavigationController.swift │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ ├── Info.plist │ └── BaseTabbarController.swift ├── podfile ├── SwifterProjectTests │ ├── Info.plist │ └── SwifterProjectTests.swift ├── SwifterProjectUITests │ ├── Info.plist │ └── SwifterProjectUITests.swift └── Podfile.lock ├── .gitignore └── README.md /Swift知识点/Swift关键字/README.md: -------------------------------------------------------------------------------- 1 | # 100-tips-demo 2 | 学习100个Swift必备tips的Demo 3 | -------------------------------------------------------------------------------- /GIF/entry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunshineBrother/SwiftTools/HEAD/GIF/entry.png -------------------------------------------------------------------------------- /GIF/下拉列表.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunshineBrother/SwiftTools/HEAD/GIF/下拉列表.gif -------------------------------------------------------------------------------- /GIF/倒计时.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunshineBrother/SwiftTools/HEAD/GIF/倒计时.gif -------------------------------------------------------------------------------- /GIF/UIButton扩展.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunshineBrother/SwiftTools/HEAD/GIF/UIButton扩展.png -------------------------------------------------------------------------------- /GIF/UILabel扩展.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunshineBrother/SwiftTools/HEAD/GIF/UILabel扩展.gif -------------------------------------------------------------------------------- /GIF/UITextView.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunshineBrother/SwiftTools/HEAD/GIF/UITextView.gif -------------------------------------------------------------------------------- /GIF/UITextField.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunshineBrother/SwiftTools/HEAD/GIF/UITextField.gif -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/KVO/KVO/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Lock/Lock/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Option/Option/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/关联对象/关联对象/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/柯里化1/柯里化1/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /SwifterProject/SwifterProject/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/局部scope/局部scope/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test/test/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test1/test1/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Lock/Lock/Lock-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/关联对象/关联对象/关联对象-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Option/Option/Option-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/局部scope/局部scope/局部scope-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | -------------------------------------------------------------------------------- /SwifterProject/SwifterProject/Assets.xcassets/Order.imageset/Order@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunshineBrother/SwiftTools/HEAD/SwifterProject/SwifterProject/Assets.xcassets/Order.imageset/Order@2x.png -------------------------------------------------------------------------------- /SwifterProject/SwifterProject/Assets.xcassets/home.imageset/home@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunshineBrother/SwiftTools/HEAD/SwifterProject/SwifterProject/Assets.xcassets/home.imageset/home@2x.png -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/可选项/可选项/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 可选项 4 | // 5 | // Created by yunna on 2020/3/30. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | -------------------------------------------------------------------------------- /SwifterProject/SwifterProject/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test/test/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // test 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/Any/Any/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // Any 4 | // 5 | // Created by yunna on 2020/3/27. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class A { 12 | 13 | } 14 | let typeA: A.Type = A.self 15 | 16 | AnyClass 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test/test/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // test 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Lock/Lock/OCViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCViewController.h 3 | // Lock 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface OCViewController : UIViewController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/关联对象/关联对象/OCViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCViewController.h 3 | // 关联对象 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface OCViewController : UIViewController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Option/Option/OCViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCViewController.h 3 | // Option 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface OCViewController : UIViewController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/局部scope/局部scope/OCViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCViewController.h 3 | // 局部scope 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface OCViewController : UIViewController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test/test/SceneDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.h 3 | // test 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SceneDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow * window; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/默认参数/默认参数/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 默认参数 4 | // 5 | // Created by yunna on 2020/3/27. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | //NSLocalizedString(<#T##key: String##String#>, comment: <#T##String#>) 13 | // 14 | 15 | 16 | func test(a:String = "1",b:String,c:String = "3"){ 17 | 18 | } 19 | 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | */build/* 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | profile 14 | *.moved-aside 15 | DerivedData 16 | .idea/ 17 | *.hmap 18 | *.xccheckout 19 | *.xcworkspace 20 | !default.xcworkspace 21 | 22 | #CocoaPods 23 | Pods 24 | !Podfile 25 | !Podfile.lock -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/Tuple/Tuple/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // Tuple 4 | // 5 | // Created by yunna on 2020/3/25. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | func swapMel1(a:inout T, b:inout T) { 12 | let temp = a 13 | a = b 14 | b = temp 15 | } 16 | 17 | func swapMel2(a:inout T, b:inout T) { 18 | (a,b) = (b,a) 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test1/test1/MyApplication.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FLApplication.swift 3 | // test1 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | class MyApplication: UIApplication { 11 | override func sendEvent(_ event: UIEvent) { 12 | super.sendEvent(event) 13 | print("Event sent:\(event)") 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Lock/Lock/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Lock 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view. 16 | } 17 | 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/关联对象/关联对象/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // 关联对象 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view. 16 | } 17 | 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /SwifterProject/SwifterProject/Assets.xcassets/Order.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "filename" : "Order@2x.png", 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SwifterProject/SwifterProject/Assets.xcassets/home.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "filename" : "home@2x.png", 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/柯里化/柯里化/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 柯里化 4 | // 5 | // Created by yunna on 2020/3/24. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | func add(_ v1:Int,_ v2:Int) -> Int { 12 | return v1 + v2 13 | } 14 | print(add(1, 2)) 15 | 16 | func add(_ v:Int) -> (Int) -> Int { 17 | return {$0 + v} 18 | } 19 | print(add(1)(2)) 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /SwifterProject/podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '10.0' 2 | inhibit_all_warnings! 3 | 4 | target 'SwifterProject' do 5 | use_frameworks! 6 | pod 'BeeHive' 7 | pod 'SwiftLint' 8 | 9 | 10 | pod 'ThirdLib', :path => 'Modules/ThirdLib' 11 | pod 'JHSwifterSwift', :path => 'Modules/JHSwifterSwift' 12 | pod 'Request', :path => 'Modules/Request' 13 | pod 'HomeModule', :path => 'Modules/HomeModule' 14 | pod 'OrderModule', :path => 'Modules/OrderModule' 15 | 16 | 17 | end 18 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/自省/自省/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 自省 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | class ClassA: NSObject {} 13 | class ClassB: ClassA {} 14 | 15 | let obj1 = ClassA() 16 | let obj2 = ClassB() 17 | 18 | print(obj1.isKind(of: ClassA.self)) 19 | print(obj2.isMember(of: ClassA.self)) 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Lock/Lock/OCViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCViewController.m 3 | // Lock 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | #import "OCViewController.h" 10 | 11 | @interface OCViewController () 12 | 13 | @end 14 | 15 | @implementation OCViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view. 20 | } 21 | 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test/test/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // test 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view. 20 | } 21 | 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/lazy/lazy/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // lazy 4 | // 5 | // Created by yunna on 2020/3/30. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class A { 12 | lazy var str:String = { 13 | let str = "Hello" 14 | print("首次访问的时候输出") 15 | return str 16 | }() 17 | 18 | lazy var str1 = "word" 19 | } 20 | 21 | let a = A() 22 | print(a.str) 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/GCD/GCD/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // GCD 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | class Person { 13 | func test() { 14 | delay(2) { 15 | print("------") 16 | } 17 | } 18 | } 19 | 20 | Person().test() 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Option/Option/OCViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCViewController.m 3 | // Option 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | #import "OCViewController.h" 10 | 11 | @interface OCViewController () 12 | 13 | @end 14 | 15 | @implementation OCViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view. 20 | 21 | 22 | 23 | } 24 | 25 | 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test/test/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // test 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | NSString * appDelegateClassName; 14 | @autoreleasepool { 15 | appDelegateClassName = NSStringFromClass([AppDelegate class]); 16 | } 17 | return UIApplicationMain(argc, argv, nil, appDelegateClassName); 18 | } 19 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/指针/指针/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 指针 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test1/test1/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // test1 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view. 16 | } 17 | 18 | 19 | @IBAction func test(_ sender: Any) { 20 | print("--------") 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test1/test1/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // test1 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | 12 | UIApplicationMain( 13 | CommandLine.argc, 14 | UnsafeMutableRawPointer(CommandLine.unsafeArgv) 15 | .bindMemory( 16 | to: UnsafeMutablePointer.self, 17 | capacity: Int(CommandLine.argc)), 18 | NSStringFromClass(MyApplication.self), 19 | NSStringFromClass(AppDelegate.self) 20 | ) 21 | 22 | -------------------------------------------------------------------------------- /SwifterProject/SwifterProject/Service.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | service 7 | HomeModule.HomeServerProtocol 8 | impl 9 | HomeModule.HomeServerHandle 10 | 11 | 12 | service 13 | OrderModule.OrderServerProtocol 14 | impl 15 | OrderModule.OrderServerHandle 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/Mutating/Mutating/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // Mutating 4 | // 5 | // Created by yunna on 2020/3/25. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | protocol Vehicle { 13 | var numberOfWheels:Int{get} 14 | mutating func changeNumberOfWheels() 15 | } 16 | 17 | struct MyCar:Vehicle { 18 | var numberOfWheels: Int = 4 19 | 20 | mutating func changeNumberOfWheels() { 21 | numberOfWheels = 4 22 | } 23 | } 24 | 25 | class Cars: Vehicle { 26 | var numberOfWheels: Int = 0 27 | func changeNumberOfWheels() { 28 | numberOfWheels = 2 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/autoclosure/autoclosure/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // autoclosure 4 | // 5 | // Created by yunna on 2020/3/25. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | func getFirstPositive1(_ v1:Int, _ v2:Int) -> Int { 12 | return v1 > 0 ? v1 : v2 13 | } 14 | getFirstPositive1(1, 2) 15 | 16 | 17 | func getFirstPositive2(_ v1:Int, _ v2:() -> Int) -> Int { 18 | return v1 > 0 ? v1 : v2() 19 | } 20 | getFirstPositive2(1, 2) //这个报错 21 | getFirstPositive2(1, {2}) 22 | 23 | func getFirstPositive3(_ v1:Int, _ v2:@autoclosure () -> Int) -> Int { 24 | return v1 > 0 ? v1 : v2() 25 | } 26 | getFirstPositive3(1, 2) 27 | 28 | 29 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/实例化方法动态调用/实例化方法动态调用/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 实例化方法动态调用 4 | // 5 | // Created by yunna on 2020/4/2. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | 13 | class MyClass { 14 | func method(number: Int) -> Int { 15 | return number + 1 16 | } 17 | } 18 | 19 | let cls = MyClass() 20 | cls.method(number: 1) 21 | 22 | 23 | 24 | let f = MyClass.method 25 | let object = MyClass() 26 | let result = f(object)(1) 27 | 28 | let f1 = { (obj: MyClass) in obj.method } 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Option/Option/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Option 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | struct YourOption: OptionSet { 11 | let rawValue: UInt 12 | static let none = YourOption(rawValue: 0) 13 | static let option1 = YourOption(rawValue: 1) 14 | static let option2 = YourOption(rawValue: 1 << 1) 15 | //... 16 | } 17 | class ViewController: UIViewController { 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | // Do any additional setup after loading the view. 22 | 23 | 24 | 25 | 26 | } 27 | 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /SwifterProject/SwifterProject/Module.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | moduleClasses 6 | 7 | 8 | OrderModule 9 | OrderModule.OrderModule 10 | moduleLevel 11 | 1 12 | modulePriority 13 | 600 14 | 15 | 16 | moduleClass 17 | HomeModule.HomeModule 18 | moduleLevel 19 | 1 20 | modulePriority 21 | 600 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/柯里化1/柯里化1/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // 柯里化1 4 | // 5 | // Created by yunna on 2020/3/24. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view. 16 | 17 | let btn = UIButton(frame: CGRect(x: 50, y: 100, width: 100, height: 50)) 18 | btn.backgroundColor = .gray 19 | view.addSubview(btn) 20 | btn.target(forAction: <#T##Selector#>, withSender: <#T##Any?#>) 21 | 22 | 23 | } 24 | 25 | 26 | 27 | 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /Swift知识点/函数式swift/函数式思想/函数式思想/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 函数式思想 4 | // 5 | // Created by yunna on 2020/4/9. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | typealias Distance = Double 12 | //1 13 | struct Position { 14 | var x: Double 15 | var y: Double 16 | } 17 | 18 | extension Position { 19 | func within(range: Distance) -> Bool { 20 | return sqrt(x * x + y * y) <= range 21 | } 22 | } 23 | 24 | //2 25 | struct Ship { 26 | var position: Position 27 | var firingRange: Distance 28 | var unsafeRange: Distance 29 | } 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/尾递归/尾递归/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 尾递归 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | func sum(_ n:Int) -> Int { 12 | if n == 0 { 13 | return 0 14 | } 15 | return n + sum(n - 1) 16 | } 17 | 18 | sum(1000000) 19 | 20 | func tailSum(_ n: Int) -> Int { 21 | func sumInternal(_ n: Int, current: Int) -> Int { 22 | if n == 0 { 23 | return current 24 | } else { 25 | return sumInternal(n - 1, current: current + n) 26 | } 27 | } 28 | 29 | return sumInternal(n, current: 0) 30 | } 31 | 32 | print(tailSum(1000000)) 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /SwifterProject/SwifterProjectTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/KVO/KVOTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/KVO/KVOUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Lock/LockTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Lock/LockUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/关联对象/关联对象Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/关联对象/关联对象UITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/柯里化1/柯里化1Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/柯里化1/柯里化1UITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /SwifterProject/SwifterProjectUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Option/OptionTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Option/OptionUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/局部scope/局部scopeTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/关联对象/关联对象/OCViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCViewController.m 3 | // 关联对象 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | #import "OCViewController.h" 10 | 11 | @interface OCViewController () 12 | 13 | @end 14 | 15 | @implementation OCViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view. 20 | } 21 | 22 | /* 23 | #pragma mark - Navigation 24 | 25 | // In a storyboard-based application, you will often want to do a little preparation before navigation 26 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 27 | // Get the new view controller using [segue destinationViewController]. 28 | // Pass the selected object to the new view controller. 29 | } 30 | */ 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/局部scope/局部scopeUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test/testTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test/testUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test1/test1Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test1/test1UITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/值类型和引用类型/值类型和引用类型/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 值类型和引用类型 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct CoordinateStruct { 12 | var x: Double 13 | var y: Double 14 | } 15 | 16 | var coordA = CoordinateStruct(x: 0, y: 0) 17 | var coordB = coordA 18 | 19 | coordA.x = 100.0 20 | print("coordA.x -> \(coordA.x)") 21 | print("coordB.x -> \(coordB.x)") 22 | 23 | withUnsafePointer(to: &coordA) { print("\($0)") } 24 | withUnsafePointer(to: &coordB) { print("\($0)") } 25 | 26 | 27 | class Dog { 28 | var height = 0.0 29 | var weight = 0.0 30 | } 31 | 32 | var dogA = Dog() 33 | var dogB = dogA 34 | 35 | dogA.height = 50.0 36 | print(Unmanaged.passUnretained(dogA).toOpaque()) 37 | print(Unmanaged.passUnretained(dogB).toOpaque()) 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/下标/下标/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 下标 4 | // 5 | // Created by yunna on 2020/3/26. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | extension Array { 12 | subscript(input: [Int]) -> ArraySlice { 13 | get { 14 | var result = ArraySlice() 15 | for i in input { 16 | assert(i < self.count, "Index out of range") 17 | result.append(self[i]) 18 | } 19 | return result 20 | } 21 | set { 22 | for (index,i) in input.enumerated() { 23 | assert(i < self.count, "Index out of range") 24 | self[i] = newValue[index] 25 | } 26 | } 27 | } 28 | } 29 | 30 | var arr = ["a","b","c","d","z"] 31 | print(arr[[0,3]]) //["a", "d"] 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/关联对象/关联对象Tests/____Tests.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import XCTest 4 | @testable import ___VARIABLE_productName:identifier___ 5 | 6 | class ___FILEBASENAMEASIDENTIFIER___: XCTestCase { 7 | 8 | override func setUp() { 9 | // Put setup code here. This method is called before the invocation of each test method in the class. 10 | } 11 | 12 | override func tearDown() { 13 | // Put teardown code here. This method is called after the invocation of each test method in the class. 14 | } 15 | 16 | func testExample() { 17 | // This is an example of a functional test case. 18 | // Use XCTAssert and related functions to verify your tests produce the correct results. 19 | } 20 | 21 | func testPerformanceExample() { 22 | // This is an example of a performance test case. 23 | self.measure { 24 | // Put the code you want to measure the time of here. 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/柯里化1/柯里化1Tests/___1Tests.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import XCTest 4 | @testable import ___VARIABLE_productName:identifier___ 5 | 6 | class ___FILEBASENAMEASIDENTIFIER___: XCTestCase { 7 | 8 | override func setUp() { 9 | // Put setup code here. This method is called before the invocation of each test method in the class. 10 | } 11 | 12 | override func tearDown() { 13 | // Put teardown code here. This method is called after the invocation of each test method in the class. 14 | } 15 | 16 | func testExample() { 17 | // This is an example of a functional test case. 18 | // Use XCTAssert and related functions to verify your tests produce the correct results. 19 | } 20 | 21 | func testPerformanceExample() { 22 | // This is an example of a performance test case. 23 | self.measure { 24 | // Put the code you want to measure the time of here. 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/动态运行/动态运行/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 动态运行 4 | // 5 | // Created by yunna on 2020/3/27. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class Pet {} 12 | class Dog:Pet {} 13 | class Cat:Pet {} 14 | 15 | func eat(_ pet:Pet) { 16 | print("pet eat") 17 | } 18 | 19 | func eat(_ dog:Dog) { 20 | print("dog eat") 21 | } 22 | 23 | func eat(_ cat:Cat) { 24 | print("cat eat") 25 | } 26 | 27 | func eats(_ pet:Pet,_ cat:Cat) { 28 | eat(pet) 29 | eat(cat) 30 | } 31 | eats(Dog(), Cat()) 32 | //pet eat 33 | //cat eat 34 | 35 | func eats1(_ pet:Pet,_ cat:Cat) { 36 | if let aCat = pet as? Cat { 37 | eat(aCat) 38 | }else if let aDog = pet as? Cat{ 39 | eat(aDog) 40 | } 41 | 42 | eat(cat) 43 | } 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/属性观察器/属性观察器/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 属性观察器 4 | // 5 | // Created by yunna on 2020/3/30. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class Person { 12 | var age:Int = 0{ 13 | willSet{ 14 | print("即将将年龄从\(age)设置为\(newValue)") 15 | } 16 | didSet{ 17 | print("已经将年龄从\(oldValue)设置为\(age)") 18 | } 19 | } 20 | } 21 | 22 | let p = Person() 23 | p.age = 10 24 | 25 | 26 | 27 | class A { 28 | var number:Int { 29 | get{ 30 | print("get 1") 31 | return 1 32 | } 33 | set{ 34 | print("set \(newValue)") 35 | } 36 | } 37 | } 38 | 39 | class B:A { 40 | override var number: Int{ 41 | willSet{ 42 | print("willSet") 43 | } 44 | didSet{ 45 | print("didSet") 46 | } 47 | } 48 | } 49 | 50 | let b = B() 51 | b.number = 10 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test/testTests/testTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // testTests.m 3 | // testTests 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface testTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation testTests 16 | 17 | - (void)setUp { 18 | // Put setup code here. This method is called before the invocation of each test method in the class. 19 | } 20 | 21 | - (void)tearDown { 22 | // Put teardown code here. This method is called after the invocation of each test method in the class. 23 | } 24 | 25 | - (void)testExample { 26 | // This is an example of a functional test case. 27 | // Use XCTAssert and related functions to verify your tests produce the correct results. 28 | } 29 | 30 | - (void)testPerformanceExample { 31 | // This is an example of a performance test case. 32 | [self measureBlock:^{ 33 | // Put the code you want to measure the time of here. 34 | }]; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/KVO/KVOTests/KVOTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // KVOTests.swift 3 | // KVOTests 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import KVO 11 | 12 | class KVOTests: XCTestCase { 13 | 14 | override func setUp() { 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | } 21 | 22 | func testExample() { 23 | // This is an example of a functional test case. 24 | // Use XCTAssert and related functions to verify your tests produce the correct results. 25 | } 26 | 27 | func testPerformanceExample() { 28 | // This is an example of a performance test case. 29 | self.measure { 30 | // Put the code you want to measure the time of here. 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Lock/LockTests/LockTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LockTests.swift 3 | // LockTests 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import Lock 11 | 12 | class LockTests: XCTestCase { 13 | 14 | override func setUp() { 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | } 21 | 22 | func testExample() { 23 | // This is an example of a functional test case. 24 | // Use XCTAssert and related functions to verify your tests produce the correct results. 25 | } 26 | 27 | func testPerformanceExample() { 28 | // This is an example of a performance test case. 29 | self.measure { 30 | // Put the code you want to measure the time of here. 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Option/OptionTests/OptionTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OptionTests.swift 3 | // OptionTests 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import Option 11 | 12 | class OptionTests: XCTestCase { 13 | 14 | override func setUp() { 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | } 21 | 22 | func testExample() { 23 | // This is an example of a functional test case. 24 | // Use XCTAssert and related functions to verify your tests produce the correct results. 25 | } 26 | 27 | func testPerformanceExample() { 28 | // This is an example of a performance test case. 29 | self.measure { 30 | // Put the code you want to measure the time of here. 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/associatedtype/associatedtype/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // associatedtype 4 | // 5 | // Created by yunna on 2020/3/26. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol Food { } 12 | 13 | protocol Animal { 14 | associatedtype F: Food 15 | func eat(_ food: F) 16 | 17 | } 18 | 19 | struct Meat: Food { } 20 | struct Grass: Food { } 21 | 22 | 23 | //struct Tiger: Animal { 24 | // func eat(_ food: Food) { 25 | // 26 | // } 27 | //} 28 | // 29 | 30 | struct Tiger: Animal { 31 | func eat(_ food: Meat) { 32 | print("eat \(food)") 33 | } 34 | } 35 | 36 | 37 | //func isDangerous(animal: Animal) -> Bool { 38 | // if animal is Tiger { 39 | // return true 40 | // } else { 41 | // return false 42 | // } 43 | //} 44 | 45 | 46 | func isDangerous(animal: T) -> Bool { 47 | if animal is Tiger { 48 | return true 49 | } else { 50 | return false 51 | } 52 | } 53 | 54 | isDangerous(animal: Tiger()) // true 55 | 56 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/局部scope/局部scopeTests/__scopeTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // __scopeTests.swift 3 | // 局部scopeTests 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import __scope 11 | 12 | class __scopeTests: XCTestCase { 13 | 14 | override func setUp() { 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | } 21 | 22 | func testExample() { 23 | // This is an example of a functional test case. 24 | // Use XCTAssert and related functions to verify your tests produce the correct results. 25 | } 26 | 27 | func testPerformanceExample() { 28 | // This is an example of a performance test case. 29 | self.measure { 30 | // Put the code you want to measure the time of here. 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test1/test1Tests/test1Tests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // test1Tests.swift 3 | // test1Tests 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import test1 11 | 12 | class test1Tests: XCTestCase { 13 | 14 | override func setUp() { 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | } 21 | 22 | func testExample() { 23 | // This is an example of a functional test case. 24 | // Use XCTAssert and related functions to verify your tests produce the correct results. 25 | } 26 | 27 | func testPerformanceExample() { 28 | // This is an example of a performance test case. 29 | self.measure { 30 | // Put the code you want to measure the time of here. 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/反射/反射/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 反射 4 | // 5 | // Created by yunna on 2020/3/30. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct Person { 12 | let name:String 13 | let age:Int 14 | } 15 | 16 | let xiaoming = Person(name: "小明", age: 10) 17 | let r = Mirror(reflecting: xiaoming) 18 | 19 | print("xiaoming是\(r.displayStyle)") 20 | print("属性个数:\(r.children.count)") 21 | 22 | for child in r.children{ 23 | print("属性名:\(child.label) 值:\(child.value)") 24 | } 25 | 26 | print("-------") 27 | print(dump(xiaoming)) 28 | 29 | 30 | 31 | 32 | func valueFrom(_ object: Any, key: String) -> Any? { 33 | let mirror = Mirror(reflecting: object) 34 | for child in mirror.children { 35 | let (targetKey, targetMirror) = (child.label, child.value) 36 | if key == targetKey { 37 | return targetMirror 38 | } 39 | } 40 | return nil 41 | } 42 | 43 | 44 | if let name = valueFrom(xiaoming, key: "name") as? String { 45 | print("通过 key 得到值: \(name)") 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/Optional/Optional/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // Optional 4 | // 5 | // Created by yunna on 2020/4/1. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | var string:String? = "string" 13 | var anotherString:String?? = string 14 | var literalString:String?? = "string" 15 | var a: Optional = Optional.some(Optional.some("string")) 16 | var b: Optional = Optional.some(string) 17 | var age1: Optional = .some(10) 18 | print(anotherString) 19 | print(literalString) 20 | print(anotherString == literalString) 21 | 22 | 23 | 24 | var aNil:String? = nil 25 | var anoterNil:String?? = aNil 26 | var literalNil:String?? = nil 27 | print(anoterNil) 28 | print(literalNil) 29 | print(anoterNil == literalNil) 30 | 31 | 32 | 33 | 34 | let arr = [1,2,3] 35 | let doubled = arr.map { 36 | $0 * 2 37 | } 38 | print(doubled) 39 | 40 | //let arr1 = [1,2,nil] 41 | //let doubled1 = arr1.map { 42 | // $0 * 2 43 | //} 44 | //print(doubled1) 45 | let num: Int? = nil 46 | let result = num.map { 47 | $0 * 2 48 | } 49 | 50 | print(result) 51 | -------------------------------------------------------------------------------- /SwifterProject/SwifterProjectTests/SwifterProjectTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwifterProjectTests.swift 3 | // SwifterProjectTests 4 | // 5 | // Created by jiangjunhui on 2021/9/23. 6 | // 7 | 8 | import XCTest 9 | @testable import SwifterProject 10 | 11 | class SwifterProjectTests: XCTestCase { 12 | 13 | override func setUpWithError() throws { 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | } 16 | 17 | override func tearDownWithError() throws { 18 | // Put teardown code here. This method is called after the invocation of each test method in the class. 19 | } 20 | 21 | func testExample() throws { 22 | // This is an example of a functional test case. 23 | // Use XCTAssert and related functions to verify your tests produce the correct results. 24 | } 25 | 26 | func testPerformanceExample() throws { 27 | // This is an example of a performance test case. 28 | self.measure { 29 | // Put the code you want to measure the time of here. 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/局部scope/局部scope/OCViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCViewController.m 3 | // 局部scope 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | #import "OCViewController.h" 10 | 11 | @interface OCViewController () 12 | 13 | @end 14 | 15 | @implementation OCViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view. 20 | } 21 | 22 | 23 | 24 | - (void)loadView { 25 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; 26 | { 27 | UILabel *titleLabel = [[UILabel alloc] 28 | initWithFrame:CGRectMake(150, 30, 200, 40)]; 29 | titleLabel.textColor = [UIColor redColor]; 30 | titleLabel.text = @"Title"; 31 | [view addSubview:titleLabel]; 32 | } 33 | 34 | { 35 | UILabel *textLabel = [[UILabel alloc] 36 | initWithFrame:CGRectMake(150, 80, 200, 40)]; 37 | textLabel.textColor = [UIColor redColor]; 38 | textLabel.text = @"Text"; 39 | [view addSubview:textLabel]; 40 | } 41 | 42 | self.view = view; 43 | } 44 | 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/GCD/GCD/GCDTool.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GCDTool.swift 3 | // GCD 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | typealias Task = (_ cancel : Bool) -> Void 12 | 13 | @discardableResult 14 | func delay(_ time: TimeInterval, task: @escaping ()->()) -> Task? { 15 | 16 | func dispatch_later(block: @escaping ()->()) { 17 | let t = DispatchTime.now() + time 18 | DispatchQueue.main.asyncAfter(deadline: t, execute: block) 19 | } 20 | 21 | var closure: (()->Void)? = task 22 | var result: Task? 23 | 24 | let delayedClosure: Task = { 25 | cancel in 26 | if let internalClosure = closure { 27 | if (cancel == false) { 28 | DispatchQueue.main.async(execute: internalClosure) 29 | } 30 | } 31 | closure = nil 32 | result = nil 33 | } 34 | 35 | result = delayedClosure 36 | dispatch_later { 37 | if let delayedClosure = result { 38 | delayedClosure(false) 39 | } 40 | } 41 | return result; 42 | } 43 | func cancel(_ task: Task?) { 44 | task?(true) 45 | } 46 | -------------------------------------------------------------------------------- /SwifterProject/SwifterProject/BaseNavigationController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SwifterProject 4 | // 5 | // Created by jiangjunhui on 2021/9/23. 6 | // 7 | 8 | import UIKit 9 | 10 | class BaseNavigationController: UINavigationController, UINavigationControllerDelegate { 11 | var pushing = false 12 | override func viewDidLoad() { 13 | super.viewDidLoad() 14 | self.delegate = self 15 | 16 | } 17 | 18 | override func pushViewController(_ viewController: UIViewController, animated: Bool) { 19 | if pushing == true { 20 | return 21 | } else { 22 | pushing = true 23 | } 24 | // 当导航控制器的子视图数量大于1 的时候,隐藏tabbar 25 | if self.viewControllers.count > 0 { 26 | viewController.hidesBottomBarWhenPushed = true 27 | 28 | } 29 | super.pushViewController(viewController, animated: animated) 30 | } 31 | 32 | func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) { 33 | pushing = false 34 | } 35 | } 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/条件编译/条件编译/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 条件编译 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import AVKit 11 | 12 | class MyPerson { 13 | func MyPrint() { 14 | #if FREE_VERSION 15 | print("免费版本") 16 | #else 17 | print("付费版本") 18 | #endif 19 | } 20 | 21 | 22 | func myPrint1() { 23 | #if swift(>=14.0) 24 | print(">=14.0") 25 | #else 26 | print("<14.0") 27 | #endif 28 | 29 | } 30 | } 31 | 32 | 33 | 34 | 35 | #if os(macOS) 36 | typealias Color = NSColor 37 | #else 38 | typealias Color = UIColor 39 | #endif 40 | 41 | 42 | 43 | #if arch(x86_64) 44 | 45 | #else 46 | 47 | #endif 48 | 49 | 50 | #if swift(>=14.0) 51 | 52 | #else 53 | 54 | #endif 55 | 56 | 57 | 58 | 59 | let p = MyPerson() 60 | p.myPrint1() 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/柯里化1/柯里化1/test.swift: -------------------------------------------------------------------------------- 1 | // 2 | // test.swift 3 | // 柯里化1 4 | // 5 | // Created by yunna on 2020/3/24. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol TargetAction { 12 | func performAction() 13 | } 14 | 15 | struct TargetActionWrapper: 16 | TargetAction { 17 | weak var target: T? 18 | let action: (T) -> () -> () 19 | 20 | func performAction() -> () { 21 | if let t = target { 22 | action(t)() 23 | } 24 | } 25 | } 26 | 27 | enum ControlEvent { 28 | case TouchUpInside 29 | case ValueChanged 30 | 31 | } 32 | 33 | 34 | class Control { 35 | var actions = [ControlEvent: TargetAction]() 36 | 37 | func setTarget(target: T, 38 | action: @escaping (T) -> () -> (), 39 | controlEvent: ControlEvent) { 40 | 41 | actions[controlEvent] = TargetActionWrapper( 42 | target: target, action: action) 43 | } 44 | 45 | func removeTargetForControlEvent(controlEvent: ControlEvent) { 46 | actions[controlEvent] = nil 47 | } 48 | 49 | func performActionForControlEvent(controlEvent: ControlEvent) { 50 | actions[controlEvent]?.performAction() 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/Sequence/Sequence/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // Sequence 4 | // 5 | // Created by yunna on 2020/3/25. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | let animals = ["Antelope", "Butterfly", "Camel", "Dolphin"] 12 | for animal in animals { 13 | print(animal) 14 | } 15 | 16 | 17 | //我们先实现一个IteratorProtocol协议类型 18 | class ReverseIterator: IteratorProtocol { 19 | typealias Element = T 20 | var array: [Element] 21 | var currentIndex = 0 22 | 23 | init(array: [Element]) { 24 | self.array = array 25 | currentIndex = array.count - 1 26 | } 27 | func next() -> Element? { 28 | if currentIndex < 0{ 29 | return nil 30 | } 31 | else { 32 | let element = array[currentIndex] 33 | currentIndex -= 1 34 | return element 35 | } 36 | } 37 | } 38 | 39 | // 然后我们来定义 Sequence 40 | struct ReverseSequence:Sequence { 41 | var array:[T] 42 | init (array: [T]) { 43 | self.array = array 44 | } 45 | typealias Iterator = ReverseIterator 46 | func makeIterator() -> ReverseIterator { 47 | return ReverseIterator(array: self.array) 48 | } 49 | } 50 | 51 | for item in ReverseSequence(array: animals){ 52 | print(item) 53 | } 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/操作符/操作符/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 操作符 4 | // 5 | // Created by yunna on 2020/3/25. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct Vector2D { 12 | var x:CGFloat = 0 13 | var y:CGFloat = 0 14 | } 15 | 16 | let v1 = Vector2D(x: 2.0, y: 3.0) 17 | let v2 = Vector2D(x: 1.0, y: 4.0) 18 | 19 | func +(left:Vector2D,right:Vector2D) -> Vector2D { 20 | Vector2D(x: left.x + right.x, y: left.y + right.y) 21 | } 22 | let v3 = v1 + v2 23 | 24 | 25 | 26 | /// 定义优先级组 27 | precedencegroup MyPrecedence { 28 | // higherThan: AdditionPrecedence // 优先级,比加法运算高 29 | lowerThan: AdditionPrecedence // 优先级, 比加法运算低 30 | associativity: none // 结合方向:left, right or none 31 | assignment: false // true=赋值运算符,false=非赋值运算符 32 | } 33 | 34 | infix operator +++: MyPrecedence // 继承 MyPrecedence 优先级组 35 | // infix operator +++: AdditionPrecedence // 也可以直接继承加法优先级组(AdditionPrecedence)或其他优先级组 36 | func +++(left: Int, right: Int) -> Int { 37 | return left+right*2 38 | } 39 | 40 | print(2+++3) // 8 41 | 42 | prefix operator ==+ 43 | prefix func ==+(left: Int) -> Int { 44 | 45 | return left*2 46 | } 47 | print(==+2) // 4 48 | 49 | 50 | 51 | postfix operator +== 52 | postfix func +==(right: Int) -> Int { 53 | 54 | return right*3 55 | } 56 | print(2+==) // 6 57 | 58 | 59 | -------------------------------------------------------------------------------- /SwifterProject/SwifterProject/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SwifterProject 4 | // 5 | // Created by jiangjunhui on 2021/9/23. 6 | // 7 | 8 | import UIKit 9 | import BeeHive 10 | 11 | @UIApplicationMain 12 | class AppDelegate: BHAppDelegate { 13 | 14 | override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 15 | 16 | 17 | BHContext.shareInstance().application = application 18 | BHContext.shareInstance().launchOptions = launchOptions 19 | BHContext.shareInstance().moduleConfigName = "Module" 20 | BHContext.shareInstance().serviceConfigName = "Service" 21 | 22 | BeeHive.shareInstance().enableException = true 23 | BeeHive.shareInstance().context = BHContext.shareInstance() 24 | 25 | 26 | super.application(application, didFinishLaunchingWithOptions: launchOptions) 27 | 28 | window = UIWindow(frame: UIScreen.main.bounds) 29 | self.window?.backgroundColor = .white 30 | let root = BaseTabbarController() 31 | window?.rootViewController = root 32 | self.window?.makeKeyAndVisible() 33 | 34 | return true 35 | } 36 | 37 | 38 | override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { 39 | 40 | return true 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/协议/协议/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 协议 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | protocol MyProtocol { 13 | func mustProtocolMethod() //必须实现方法 14 | func mustProtocolMethod1() //必须实现方法 15 | } 16 | 17 | 18 | class MyClass: MyProtocol { 19 | func mustProtocolMethod() { 20 | print("MyClass-->必须实现方法:mustProtocolMethod") 21 | } 22 | 23 | func mustProtocolMethod1() { 24 | print("MyClass-->必须实现方法:mustProtocolMethod1") 25 | } 26 | 27 | } 28 | 29 | let cls = MyClass() 30 | cls.mustProtocolMethod() 31 | cls.mustProtocolMethod1() 32 | 33 | 34 | 35 | 36 | 37 | @objc protocol MyProtocol1 { 38 | @objc optional func optionalProtocolMethod() //可选方法 39 | func mustProtocolMethod1() //必须实现方法 40 | } 41 | 42 | 43 | class MyClass1: MyProtocol1 { 44 | func mustProtocolMethod1() { 45 | print("MyClass1-->必须实现方法:protocolMethod1") 46 | } 47 | } 48 | 49 | let cls1 = MyClass1() 50 | cls1.mustProtocolMethod1() 51 | 52 | 53 | 54 | protocol MyProtocol2 { 55 | func optionalProtocolMethod1() //可选方法 56 | func optionalProtocolMethod2() //可选方法 57 | func mustProtocolMethod1() //必须实现方法 58 | } 59 | 60 | extension MyProtocol2{ 61 | func optionalProtocolMethod1(){ 62 | 63 | } 64 | 65 | func optionalProtocolMethod2(){ 66 | 67 | } 68 | } 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/关联对象/关联对象UITests/____UITests.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import XCTest 4 | 5 | class ___FILEBASENAMEASIDENTIFIER___: XCTestCase { 6 | 7 | override func setUp() { 8 | // Put setup code here. This method is called before the invocation of each test method in the class. 9 | 10 | // In UI tests it is usually best to stop immediately when a failure occurs. 11 | continueAfterFailure = false 12 | 13 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 14 | } 15 | 16 | override func tearDown() { 17 | // Put teardown code here. This method is called after the invocation of each test method in the class. 18 | } 19 | 20 | func testExample() { 21 | // UI tests must launch the application that they test. 22 | let app = XCUIApplication() 23 | app.launch() 24 | 25 | // Use recording to get started writing UI tests. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testLaunchPerformance() { 30 | if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) { 31 | // This measures how long it takes to launch your application. 32 | measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) { 33 | XCUIApplication().launch() 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/柯里化1/柯里化1UITests/___1UITests.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import XCTest 4 | 5 | class ___FILEBASENAMEASIDENTIFIER___: XCTestCase { 6 | 7 | override func setUp() { 8 | // Put setup code here. This method is called before the invocation of each test method in the class. 9 | 10 | // In UI tests it is usually best to stop immediately when a failure occurs. 11 | continueAfterFailure = false 12 | 13 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 14 | } 15 | 16 | override func tearDown() { 17 | // Put teardown code here. This method is called after the invocation of each test method in the class. 18 | } 19 | 20 | func testExample() { 21 | // UI tests must launch the application that they test. 22 | let app = XCUIApplication() 23 | app.launch() 24 | 25 | // Use recording to get started writing UI tests. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testLaunchPerformance() { 30 | if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) { 31 | // This measures how long it takes to launch your application. 32 | measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) { 33 | XCUIApplication().launch() 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test/test/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // test 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | #pragma mark - UISceneSession lifecycle 25 | 26 | 27 | - (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options { 28 | // Called when a new scene session is being created. 29 | // Use this method to select a configuration to create the new scene with. 30 | return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role]; 31 | } 32 | 33 | 34 | - (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet *)sceneSessions { 35 | // Called when the user discards a scene session. 36 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 37 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 38 | } 39 | 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/KVO/KVO/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // KVO 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Lock/Lock/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Lock 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/关联对象/关联对象/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // 关联对象 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/柯里化1/柯里化1/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // 柯里化1 4 | // 5 | // Created by yunna on 2020/3/24. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Option/Option/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Option 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/局部scope/局部scope/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // 局部scope 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test1/test1/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // test1 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | 12 | //@UIApplicationMain 13 | class AppDelegate: UIResponder, UIApplicationDelegate { 14 | 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | // MARK: UISceneSession Lifecycle 23 | 24 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 25 | // Called when a new scene session is being created. 26 | // Use this method to select a configuration to create the new scene with. 27 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 28 | } 29 | 30 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 31 | // Called when the user discards a scene session. 32 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 33 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 34 | } 35 | 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/KVO/KVOUITests/KVOUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // KVOUITests.swift 3 | // KVOUITests 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class KVOUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | 16 | // In UI tests it is usually best to stop immediately when a failure occurs. 17 | continueAfterFailure = false 18 | 19 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 20 | } 21 | 22 | override func tearDown() { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | } 25 | 26 | func testExample() { 27 | // UI tests must launch the application that they test. 28 | let app = XCUIApplication() 29 | app.launch() 30 | 31 | // Use recording to get started writing UI tests. 32 | // Use XCTAssert and related functions to verify your tests produce the correct results. 33 | } 34 | 35 | func testLaunchPerformance() { 36 | if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) { 37 | // This measures how long it takes to launch your application. 38 | measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) { 39 | XCUIApplication().launch() 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Lock/LockUITests/LockUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LockUITests.swift 3 | // LockUITests 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class LockUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | 16 | // In UI tests it is usually best to stop immediately when a failure occurs. 17 | continueAfterFailure = false 18 | 19 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 20 | } 21 | 22 | override func tearDown() { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | } 25 | 26 | func testExample() { 27 | // UI tests must launch the application that they test. 28 | let app = XCUIApplication() 29 | app.launch() 30 | 31 | // Use recording to get started writing UI tests. 32 | // Use XCTAssert and related functions to verify your tests produce the correct results. 33 | } 34 | 35 | func testLaunchPerformance() { 36 | if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) { 37 | // This measures how long it takes to launch your application. 38 | measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) { 39 | XCUIApplication().launch() 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Option/OptionUITests/OptionUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OptionUITests.swift 3 | // OptionUITests 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class OptionUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | 16 | // In UI tests it is usually best to stop immediately when a failure occurs. 17 | continueAfterFailure = false 18 | 19 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 20 | } 21 | 22 | override func tearDown() { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | } 25 | 26 | func testExample() { 27 | // UI tests must launch the application that they test. 28 | let app = XCUIApplication() 29 | app.launch() 30 | 31 | // Use recording to get started writing UI tests. 32 | // Use XCTAssert and related functions to verify your tests produce the correct results. 33 | } 34 | 35 | func testLaunchPerformance() { 36 | if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) { 37 | // This measures how long it takes to launch your application. 38 | measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) { 39 | XCUIApplication().launch() 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/局部scope/局部scopeUITests/__scopeUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // __scopeUITests.swift 3 | // 局部scopeUITests 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class __scopeUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | 16 | // In UI tests it is usually best to stop immediately when a failure occurs. 17 | continueAfterFailure = false 18 | 19 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 20 | } 21 | 22 | override func tearDown() { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | } 25 | 26 | func testExample() { 27 | // UI tests must launch the application that they test. 28 | let app = XCUIApplication() 29 | app.launch() 30 | 31 | // Use recording to get started writing UI tests. 32 | // Use XCTAssert and related functions to verify your tests produce the correct results. 33 | } 34 | 35 | func testLaunchPerformance() { 36 | if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) { 37 | // This measures how long it takes to launch your application. 38 | measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) { 39 | XCUIApplication().launch() 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test1/test1UITests/test1UITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // test1UITests.swift 3 | // test1UITests 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class test1UITests: XCTestCase { 12 | 13 | override func setUp() { 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | 16 | // In UI tests it is usually best to stop immediately when a failure occurs. 17 | continueAfterFailure = false 18 | 19 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 20 | } 21 | 22 | override func tearDown() { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | } 25 | 26 | func testExample() { 27 | // UI tests must launch the application that they test. 28 | let app = XCUIApplication() 29 | app.launch() 30 | 31 | // Use recording to get started writing UI tests. 32 | // Use XCTAssert and related functions to verify your tests produce the correct results. 33 | } 34 | 35 | func testLaunchPerformance() { 36 | if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) { 37 | // This measures how long it takes to launch your application. 38 | measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) { 39 | XCUIApplication().launch() 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /SwifterProject/SwifterProjectUITests/SwifterProjectUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwifterProjectUITests.swift 3 | // SwifterProjectUITests 4 | // 5 | // Created by jiangjunhui on 2021/9/23. 6 | // 7 | 8 | import XCTest 9 | 10 | class SwifterProjectUITests: XCTestCase { 11 | 12 | override func setUpWithError() throws { 13 | // Put setup code here. This method is called before the invocation of each test method in the class. 14 | 15 | // In UI tests it is usually best to stop immediately when a failure occurs. 16 | continueAfterFailure = false 17 | 18 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 19 | } 20 | 21 | override func tearDownWithError() throws { 22 | // Put teardown code here. This method is called after the invocation of each test method in the class. 23 | } 24 | 25 | func testExample() throws { 26 | // UI tests must launch the application that they test. 27 | let app = XCUIApplication() 28 | app.launch() 29 | 30 | // Use recording to get started writing UI tests. 31 | // Use XCTAssert and related functions to verify your tests produce the correct results. 32 | } 33 | 34 | func testLaunchPerformance() throws { 35 | if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { 36 | // This measures how long it takes to launch your application. 37 | measure(metrics: [XCTApplicationLaunchMetric()]) { 38 | XCUIApplication().launch() 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test/testUITests/testUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // testUITests.m 3 | // testUITests 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface testUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation testUITests 16 | 17 | - (void)setUp { 18 | // Put setup code here. This method is called before the invocation of each test method in the class. 19 | 20 | // In UI tests it is usually best to stop immediately when a failure occurs. 21 | self.continueAfterFailure = NO; 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | - (void)tearDown { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | } 29 | 30 | - (void)testExample { 31 | // UI tests must launch the application that they test. 32 | XCUIApplication *app = [[XCUIApplication alloc] init]; 33 | [app launch]; 34 | 35 | // Use recording to get started writing UI tests. 36 | // Use XCTAssert and related functions to verify your tests produce the correct results. 37 | } 38 | 39 | - (void)testLaunchPerformance { 40 | if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) { 41 | // This measures how long it takes to launch your application. 42 | [self measureWithMetrics:@[XCTOSSignpostMetric.applicationLaunchMetric] block:^{ 43 | [[[XCUIApplication alloc] init] launch]; 44 | }]; 45 | } 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/KVO/KVO/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /SwifterProject/SwifterProject/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Lock/Lock/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Option/Option/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/关联对象/关联对象/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/柯里化1/柯里化1/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/局部scope/局部scope/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test/test/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /SwifterProject/SwifterProject/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSupportsIndirectInputEvents 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/KVO/KVO/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Lock/Lock/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/关联对象/关联对象/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/柯里化1/柯里化1/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SwifterProject/SwifterProject/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Option/Option/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/局部scope/局部scope/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SwifterProject/SwifterProject/BaseTabbarController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SwifterProject 4 | // 5 | // Created by jiangjunhui on 2021/9/23. 6 | // 7 | 8 | import UIKit 9 | import BeeHive 10 | import OrderModule 11 | import HomeModule 12 | import JHSwifterSwift 13 | 14 | class BaseTabbarController: UITabBarController { 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | 19 | 20 | if let order: OrderServerProtocol = BeeHive.shareInstance().createService(OrderServerProtocol.self) as? OrderServerProtocol { 21 | let orderVC = BaseNavigationController(rootViewController: order.getOrderController()) 22 | setupChildVC(childVC: orderVC, title: "order", normalImage: "Order", selectedImage: "Order") 23 | } 24 | 25 | 26 | if let home: HomeServerProtocol = BeeHive.shareInstance().createService(HomeServerProtocol.self) as? HomeServerProtocol { 27 | let homeVC = BaseNavigationController(rootViewController: home.getHomeController()) 28 | setupChildVC(childVC: homeVC, title: "home", normalImage: "home", selectedImage: "home") 29 | } 30 | 31 | 32 | 33 | } 34 | 35 | 36 | func setupChildVC(childVC: UIViewController, 37 | title: String, 38 | normalImage: String, 39 | selectedImage: String) { 40 | 41 | childVC.tabBarItem.title = title 42 | // tabbar正常状态下的图片 43 | childVC.tabBarItem.image = UIImage(named: normalImage) 44 | // tabbar选中状态下的图片 45 | let select = UIImage(named: selectedImage) 46 | childVC.tabBarItem.selectedImage = select?.withRenderingMode(.alwaysOriginal) 47 | self.addChild(childVC) 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test/test/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test1/test1/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/KVO/KVO/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Lock/Lock/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/关联对象/关联对象/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/柯里化1/柯里化1/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Option/Option/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/局部scope/局部scope/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /SwifterProject/SwifterProject/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test/test/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test1/test1/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/局部scope/局部scope/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // 局部scope 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | func local(_ closure: ()->()) { 12 | closure() 13 | } 14 | 15 | class ViewController: UIViewController { 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | 21 | 22 | } 23 | 24 | 25 | override func loadView() { 26 | 27 | let view = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 480)) 28 | view.backgroundColor = .white 29 | 30 | let titleLabel: UILabel = { 31 | let label = UILabel(frame: CGRect(x: 150, y: 30, width: 200, height: 40)) 32 | label.textColor = .red 33 | label.text = "Title" 34 | return label 35 | }() 36 | view.addSubview(titleLabel) 37 | 38 | let textLabel: UILabel = { 39 | let label = UILabel(frame: CGRect(x: 150, y: 80, width: 200, height: 40)) 40 | label.textColor = .red 41 | label.text = "Text" 42 | return label 43 | }() 44 | view.addSubview(textLabel) 45 | 46 | self.view = view 47 | } 48 | 49 | 50 | // override func loadView() { 51 | // let view = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 480)) 52 | // view.backgroundColor = .white 53 | // 54 | // local { 55 | // let titleLabel = UILabel(frame: CGRect(x: 150, y: 30, width: 200, height: 40)) 56 | // titleLabel.textColor = .red 57 | // titleLabel.text = "Title" 58 | // view.addSubview(titleLabel) 59 | // } 60 | // 61 | // local { 62 | // let textLabel = UILabel(frame: CGRect(x: 150, y: 80, width: 200, height: 40)) 63 | // textLabel.textColor = .red 64 | // textLabel.text = "Text" 65 | // view.addSubview(textLabel) 66 | // } 67 | // 68 | // self.view = view 69 | // } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test/test/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | SceneDelegate 36 | UISceneStoryboardFile 37 | Main 38 | 39 | 40 | 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIMainStoryboardFile 45 | Main 46 | UIRequiredDeviceCapabilities 47 | 48 | armv7 49 | 50 | UISupportedInterfaceOrientations 51 | 52 | UIInterfaceOrientationPortrait 53 | UIInterfaceOrientationLandscapeLeft 54 | UIInterfaceOrientationLandscapeRight 55 | 56 | UISupportedInterfaceOrientations~ipad 57 | 58 | UIInterfaceOrientationPortrait 59 | UIInterfaceOrientationPortraitUpsideDown 60 | UIInterfaceOrientationLandscapeLeft 61 | UIInterfaceOrientationLandscapeRight 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test/test/SceneDelegate.m: -------------------------------------------------------------------------------- 1 | #import "SceneDelegate.h" 2 | 3 | @interface SceneDelegate () 4 | 5 | @end 6 | 7 | @implementation SceneDelegate 8 | 9 | 10 | - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions { 11 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 12 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 13 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 14 | } 15 | 16 | 17 | - (void)sceneDidDisconnect:(UIScene *)scene { 18 | // Called as the scene is being released by the system. 19 | // This occurs shortly after the scene enters the background, or when its session is discarded. 20 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 21 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 22 | } 23 | 24 | 25 | - (void)sceneDidBecomeActive:(UIScene *)scene { 26 | // Called when the scene has moved from an inactive state to an active state. 27 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 28 | } 29 | 30 | 31 | - (void)sceneWillResignActive:(UIScene *)scene { 32 | // Called when the scene will move from an active state to an inactive state. 33 | // This may occur due to temporary interruptions (ex. an incoming phone call). 34 | } 35 | 36 | 37 | - (void)sceneWillEnterForeground:(UIScene *)scene { 38 | // Called as the scene transitions from the background to the foreground. 39 | // Use this method to undo the changes made on entering the background. 40 | } 41 | 42 | 43 | - (void)sceneDidEnterBackground:(UIScene *)scene { 44 | // Called as the scene transitions from the foreground to the background. 45 | // Use this method to save data, release shared resources, and store enough scene-specific state information 46 | // to restore the scene back to its current state. 47 | } 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/KVO/KVO/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | UISceneStoryboardFile 37 | Main 38 | 39 | 40 | 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIMainStoryboardFile 45 | Main 46 | UIRequiredDeviceCapabilities 47 | 48 | armv7 49 | 50 | UISupportedInterfaceOrientations 51 | 52 | UIInterfaceOrientationPortrait 53 | UIInterfaceOrientationLandscapeLeft 54 | UIInterfaceOrientationLandscapeRight 55 | 56 | UISupportedInterfaceOrientations~ipad 57 | 58 | UIInterfaceOrientationPortrait 59 | UIInterfaceOrientationPortraitUpsideDown 60 | UIInterfaceOrientationLandscapeLeft 61 | UIInterfaceOrientationLandscapeRight 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Lock/Lock/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | UISceneStoryboardFile 37 | Main 38 | 39 | 40 | 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIMainStoryboardFile 45 | Main 46 | UIRequiredDeviceCapabilities 47 | 48 | armv7 49 | 50 | UISupportedInterfaceOrientations 51 | 52 | UIInterfaceOrientationPortrait 53 | UIInterfaceOrientationLandscapeLeft 54 | UIInterfaceOrientationLandscapeRight 55 | 56 | UISupportedInterfaceOrientations~ipad 57 | 58 | UIInterfaceOrientationPortrait 59 | UIInterfaceOrientationPortraitUpsideDown 60 | UIInterfaceOrientationLandscapeLeft 61 | UIInterfaceOrientationLandscapeRight 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Option/Option/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | UISceneStoryboardFile 37 | Main 38 | 39 | 40 | 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIMainStoryboardFile 45 | Main 46 | UIRequiredDeviceCapabilities 47 | 48 | armv7 49 | 50 | UISupportedInterfaceOrientations 51 | 52 | UIInterfaceOrientationPortrait 53 | UIInterfaceOrientationLandscapeLeft 54 | UIInterfaceOrientationLandscapeRight 55 | 56 | UISupportedInterfaceOrientations~ipad 57 | 58 | UIInterfaceOrientationPortrait 59 | UIInterfaceOrientationPortraitUpsideDown 60 | UIInterfaceOrientationLandscapeLeft 61 | UIInterfaceOrientationLandscapeRight 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/关联对象/关联对象/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | UISceneStoryboardFile 37 | Main 38 | 39 | 40 | 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIMainStoryboardFile 45 | Main 46 | UIRequiredDeviceCapabilities 47 | 48 | armv7 49 | 50 | UISupportedInterfaceOrientations 51 | 52 | UIInterfaceOrientationPortrait 53 | UIInterfaceOrientationLandscapeLeft 54 | UIInterfaceOrientationLandscapeRight 55 | 56 | UISupportedInterfaceOrientations~ipad 57 | 58 | UIInterfaceOrientationPortrait 59 | UIInterfaceOrientationPortraitUpsideDown 60 | UIInterfaceOrientationLandscapeLeft 61 | UIInterfaceOrientationLandscapeRight 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/柯里化1/柯里化1/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | UISceneStoryboardFile 37 | Main 38 | 39 | 40 | 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIMainStoryboardFile 45 | Main 46 | UIRequiredDeviceCapabilities 47 | 48 | armv7 49 | 50 | UISupportedInterfaceOrientations 51 | 52 | UIInterfaceOrientationPortrait 53 | UIInterfaceOrientationLandscapeLeft 54 | UIInterfaceOrientationLandscapeRight 55 | 56 | UISupportedInterfaceOrientations~ipad 57 | 58 | UIInterfaceOrientationPortrait 59 | UIInterfaceOrientationPortraitUpsideDown 60 | UIInterfaceOrientationLandscapeLeft 61 | UIInterfaceOrientationLandscapeRight 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/局部scope/局部scope/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | UISceneStoryboardFile 37 | Main 38 | 39 | 40 | 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIMainStoryboardFile 45 | Main 46 | UIRequiredDeviceCapabilities 47 | 48 | armv7 49 | 50 | UISupportedInterfaceOrientations 51 | 52 | UIInterfaceOrientationPortrait 53 | UIInterfaceOrientationLandscapeLeft 54 | UIInterfaceOrientationLandscapeRight 55 | 56 | UISupportedInterfaceOrientations~ipad 57 | 58 | UIInterfaceOrientationPortrait 59 | UIInterfaceOrientationPortraitUpsideDown 60 | UIInterfaceOrientationLandscapeLeft 61 | UIInterfaceOrientationLandscapeRight 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test1/test1/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | UISceneStoryboardFile 37 | Main 38 | 39 | 40 | 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIMainStoryboardFile 45 | Main 46 | UIRequiredDeviceCapabilities 47 | 48 | armv7 49 | 50 | UISupportedInterfaceOrientations 51 | 52 | UIInterfaceOrientationPortrait 53 | UIInterfaceOrientationLandscapeLeft 54 | UIInterfaceOrientationLandscapeRight 55 | 56 | UISupportedInterfaceOrientations~ipad 57 | 58 | UIInterfaceOrientationPortrait 59 | UIInterfaceOrientationPortraitUpsideDown 60 | UIInterfaceOrientationLandscapeLeft 61 | UIInterfaceOrientationLandscapeRight 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Swift知识点/函数式swift/数学函数/数学函数/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // 数学函数 4 | // 5 | // Created by yunna on 2020/4/9. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | /* 8 | 9 | 10 | public func modff(_: Float, _: UnsafeMutablePointer!) -> Float 11 | public func modf(_: Double, _: UnsafeMutablePointer!) -> Double 12 | public func modfl(_: Float80, _: UnsafeMutablePointer!) -> Float80 13 | 14 | public func ldexpf(_: Float, _: Int32) -> Float 15 | public func ldexp(_: Double, _: Int32) -> Double 16 | public func ldexpl(_: Float80, _: Int32) -> Float80 17 | 18 | public func frexpf(_: Float, _: UnsafeMutablePointer!) -> Float 19 | public func frexp(_: Double, _: UnsafeMutablePointer!) -> Double 20 | public func frexpl(_: Float80, _: UnsafeMutablePointer!) -> Float80 21 | 22 | public func ilogbf(_: Float) -> Int32 23 | public func ilogb(_: Double) -> Int32 24 | public func ilogbl(_: Float80) -> Int32 25 | 26 | public func scalbnf(_: Float, _: Int32) -> Float 27 | public func scalbn(_: Double, _: Int32) -> Double 28 | public func scalbnl(_: Float80, _: Int32) -> Float80 29 | 30 | public func scalblnf(_: Float, _: Int) -> Float 31 | public func scalbln(_: Double, _: Int) -> Double 32 | public func scalblnl(_: Float80, _: Int) -> Float80 33 | 34 | public func fabsf(_: Float) -> Float 35 | public func fabs(_: Double) -> Double 36 | public func fabsl(_: Float80) -> Float80 37 | 38 | public func cbrtf(_: Float) -> Float 39 | public func cbrt(_: Double) -> Double 40 | public func cbrtl(_: Float80) -> Float80 41 | 42 | public func hypotf(_: Float, _: Float) -> Float 43 | public func hypot(_: Double, _: Double) -> Double 44 | public func hypotl(_: Float80, _: Float80) -> Float80 45 | 46 | public func powf(_: Float, _: Float) -> Float 47 | public func pow(_: Double, _: Double) -> Double 48 | public func powl(_: Float80, _: Float80) -> Float80 49 | 50 | public func sqrtf(_: Float) -> Float 51 | public func sqrt(_: Double) -> Double 52 | public func sqrtl(_: Float80) -> Float80 53 | 54 | public func erff(_: Float) -> Float 55 | public func erf(_: Double) -> Double 56 | public func erfl(_: Float80) -> Float80 57 | 58 | public func erfcf(_: Float) -> Float 59 | public func erfc(_: Double) -> Double 60 | public func erfcl(_: Float80) -> Float80 61 | 62 | */ 63 | 64 | import Foundation 65 | 66 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/KVO/KVO/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // KVO 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | 12 | 13 | class ViewController: UIViewController { 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | let obj = Class() 19 | } 20 | 21 | } 22 | 23 | 24 | 25 | 26 | class MyClass: NSObject { 27 | @objc dynamic var date = Date() 28 | } 29 | 30 | private var myContext = 0 31 | class Class: NSObject { 32 | 33 | var myObject: MyClass! 34 | 35 | override init() { 36 | super.init() 37 | myObject = MyClass() 38 | print("初始化 MyClass,当前日期: \(myObject.date)") 39 | myObject.addObserver(self, 40 | forKeyPath: "date", 41 | options: .new, 42 | context: &myContext) 43 | 44 | delay(3) { 45 | self.myObject.date = Date() 46 | } 47 | } 48 | 49 | override func observeValue(forKeyPath keyPath: String?, 50 | of object: Any?, 51 | change: [NSKeyValueChangeKey : Any]?, 52 | context: UnsafeMutableRawPointer?) 53 | { 54 | if let change = change, context == &myContext { 55 | if let newDate = change[.newKey] as? Date { 56 | print("MyClass 日期发生变化 \(newDate)") 57 | } 58 | } 59 | } 60 | } 61 | 62 | let obj = Class() 63 | 64 | 65 | 66 | 67 | class AnotherClass: NSObject { 68 | var myObject: MyClass! 69 | var observation: NSKeyValueObservation? 70 | override init() { 71 | super.init() 72 | myObject = MyClass() 73 | print("初始化 AnotherClass,当前日期: \(myObject.date)") 74 | 75 | observation = myObject.observe(\MyClass.date, options: [.new]) { (_, change) in 76 | if let newDate = change.newValue { 77 | print("AnotherClass 日期发生变化 \(newDate)") 78 | } 79 | } 80 | 81 | delay(1) { self.myObject.date = Date() } 82 | } 83 | } 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/KVO/KVO/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // KVO 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 12 | 13 | var window: UIWindow? 14 | 15 | 16 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 17 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 18 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 19 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 20 | guard let _ = (scene as? UIWindowScene) else { return } 21 | } 22 | 23 | func sceneDidDisconnect(_ scene: UIScene) { 24 | // Called as the scene is being released by the system. 25 | // This occurs shortly after the scene enters the background, or when its session is discarded. 26 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 27 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 28 | } 29 | 30 | func sceneDidBecomeActive(_ scene: UIScene) { 31 | // Called when the scene has moved from an inactive state to an active state. 32 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 33 | } 34 | 35 | func sceneWillResignActive(_ scene: UIScene) { 36 | // Called when the scene will move from an active state to an inactive state. 37 | // This may occur due to temporary interruptions (ex. an incoming phone call). 38 | } 39 | 40 | func sceneWillEnterForeground(_ scene: UIScene) { 41 | // Called as the scene transitions from the background to the foreground. 42 | // Use this method to undo the changes made on entering the background. 43 | } 44 | 45 | func sceneDidEnterBackground(_ scene: UIScene) { 46 | // Called as the scene transitions from the foreground to the background. 47 | // Use this method to save data, release shared resources, and store enough scene-specific state information 48 | // to restore the scene back to its current state. 49 | } 50 | 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Lock/Lock/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // Lock 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 12 | 13 | var window: UIWindow? 14 | 15 | 16 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 17 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 18 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 19 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 20 | guard let _ = (scene as? UIWindowScene) else { return } 21 | } 22 | 23 | func sceneDidDisconnect(_ scene: UIScene) { 24 | // Called as the scene is being released by the system. 25 | // This occurs shortly after the scene enters the background, or when its session is discarded. 26 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 27 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 28 | } 29 | 30 | func sceneDidBecomeActive(_ scene: UIScene) { 31 | // Called when the scene has moved from an inactive state to an active state. 32 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 33 | } 34 | 35 | func sceneWillResignActive(_ scene: UIScene) { 36 | // Called when the scene will move from an active state to an inactive state. 37 | // This may occur due to temporary interruptions (ex. an incoming phone call). 38 | } 39 | 40 | func sceneWillEnterForeground(_ scene: UIScene) { 41 | // Called as the scene transitions from the background to the foreground. 42 | // Use this method to undo the changes made on entering the background. 43 | } 44 | 45 | func sceneDidEnterBackground(_ scene: UIScene) { 46 | // Called as the scene transitions from the foreground to the background. 47 | // Use this method to save data, release shared resources, and store enough scene-specific state information 48 | // to restore the scene back to its current state. 49 | } 50 | 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/关联对象/关联对象/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // 关联对象 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 12 | 13 | var window: UIWindow? 14 | 15 | 16 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 17 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 18 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 19 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 20 | guard let _ = (scene as? UIWindowScene) else { return } 21 | } 22 | 23 | func sceneDidDisconnect(_ scene: UIScene) { 24 | // Called as the scene is being released by the system. 25 | // This occurs shortly after the scene enters the background, or when its session is discarded. 26 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 27 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 28 | } 29 | 30 | func sceneDidBecomeActive(_ scene: UIScene) { 31 | // Called when the scene has moved from an inactive state to an active state. 32 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 33 | } 34 | 35 | func sceneWillResignActive(_ scene: UIScene) { 36 | // Called when the scene will move from an active state to an inactive state. 37 | // This may occur due to temporary interruptions (ex. an incoming phone call). 38 | } 39 | 40 | func sceneWillEnterForeground(_ scene: UIScene) { 41 | // Called as the scene transitions from the background to the foreground. 42 | // Use this method to undo the changes made on entering the background. 43 | } 44 | 45 | func sceneDidEnterBackground(_ scene: UIScene) { 46 | // Called as the scene transitions from the foreground to the background. 47 | // Use this method to save data, release shared resources, and store enough scene-specific state information 48 | // to restore the scene back to its current state. 49 | } 50 | 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/柯里化1/柯里化1/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // 柯里化1 4 | // 5 | // Created by yunna on 2020/3/24. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 12 | 13 | var window: UIWindow? 14 | 15 | 16 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 17 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 18 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 19 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 20 | guard let _ = (scene as? UIWindowScene) else { return } 21 | } 22 | 23 | func sceneDidDisconnect(_ scene: UIScene) { 24 | // Called as the scene is being released by the system. 25 | // This occurs shortly after the scene enters the background, or when its session is discarded. 26 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 27 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 28 | } 29 | 30 | func sceneDidBecomeActive(_ scene: UIScene) { 31 | // Called when the scene has moved from an inactive state to an active state. 32 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 33 | } 34 | 35 | func sceneWillResignActive(_ scene: UIScene) { 36 | // Called when the scene will move from an active state to an inactive state. 37 | // This may occur due to temporary interruptions (ex. an incoming phone call). 38 | } 39 | 40 | func sceneWillEnterForeground(_ scene: UIScene) { 41 | // Called as the scene transitions from the background to the foreground. 42 | // Use this method to undo the changes made on entering the background. 43 | } 44 | 45 | func sceneDidEnterBackground(_ scene: UIScene) { 46 | // Called as the scene transitions from the foreground to the background. 47 | // Use this method to save data, release shared resources, and store enough scene-specific state information 48 | // to restore the scene back to its current state. 49 | } 50 | 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/Option/Option/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // Option 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 12 | 13 | var window: UIWindow? 14 | 15 | 16 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 17 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 18 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 19 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 20 | guard let _ = (scene as? UIWindowScene) else { return } 21 | } 22 | 23 | func sceneDidDisconnect(_ scene: UIScene) { 24 | // Called as the scene is being released by the system. 25 | // This occurs shortly after the scene enters the background, or when its session is discarded. 26 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 27 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 28 | } 29 | 30 | func sceneDidBecomeActive(_ scene: UIScene) { 31 | // Called when the scene has moved from an inactive state to an active state. 32 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 33 | } 34 | 35 | func sceneWillResignActive(_ scene: UIScene) { 36 | // Called when the scene will move from an active state to an inactive state. 37 | // This may occur due to temporary interruptions (ex. an incoming phone call). 38 | } 39 | 40 | func sceneWillEnterForeground(_ scene: UIScene) { 41 | // Called as the scene transitions from the background to the foreground. 42 | // Use this method to undo the changes made on entering the background. 43 | } 44 | 45 | func sceneDidEnterBackground(_ scene: UIScene) { 46 | // Called as the scene transitions from the foreground to the background. 47 | // Use this method to save data, release shared resources, and store enough scene-specific state information 48 | // to restore the scene back to its current state. 49 | } 50 | 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/局部scope/局部scope/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // 局部scope 4 | // 5 | // Created by yunna on 2020/4/8. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 12 | 13 | var window: UIWindow? 14 | 15 | 16 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 17 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 18 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 19 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 20 | guard let _ = (scene as? UIWindowScene) else { return } 21 | } 22 | 23 | func sceneDidDisconnect(_ scene: UIScene) { 24 | // Called as the scene is being released by the system. 25 | // This occurs shortly after the scene enters the background, or when its session is discarded. 26 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 27 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 28 | } 29 | 30 | func sceneDidBecomeActive(_ scene: UIScene) { 31 | // Called when the scene has moved from an inactive state to an active state. 32 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 33 | } 34 | 35 | func sceneWillResignActive(_ scene: UIScene) { 36 | // Called when the scene will move from an active state to an inactive state. 37 | // This may occur due to temporary interruptions (ex. an incoming phone call). 38 | } 39 | 40 | func sceneWillEnterForeground(_ scene: UIScene) { 41 | // Called as the scene transitions from the background to the foreground. 42 | // Use this method to undo the changes made on entering the background. 43 | } 44 | 45 | func sceneDidEnterBackground(_ scene: UIScene) { 46 | // Called as the scene transitions from the foreground to the background. 47 | // Use this method to save data, release shared resources, and store enough scene-specific state information 48 | // to restore the scene back to its current state. 49 | } 50 | 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test1/test1/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // test1 4 | // 5 | // Created by yunna on 2020/4/3. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 12 | 13 | var window: UIWindow? 14 | 15 | 16 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 17 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 18 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 19 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 20 | guard let _ = (scene as? UIWindowScene) else { return } 21 | } 22 | 23 | func sceneDidDisconnect(_ scene: UIScene) { 24 | // Called as the scene is being released by the system. 25 | // This occurs shortly after the scene enters the background, or when its session is discarded. 26 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 27 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 28 | } 29 | 30 | func sceneDidBecomeActive(_ scene: UIScene) { 31 | // Called when the scene has moved from an inactive state to an active state. 32 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 33 | } 34 | 35 | func sceneWillResignActive(_ scene: UIScene) { 36 | // Called when the scene will move from an active state to an inactive state. 37 | // This may occur due to temporary interruptions (ex. an incoming phone call). 38 | } 39 | 40 | func sceneWillEnterForeground(_ scene: UIScene) { 41 | // Called as the scene transitions from the background to the foreground. 42 | // Use this method to undo the changes made on entering the background. 43 | } 44 | 45 | func sceneDidEnterBackground(_ scene: UIScene) { 46 | // Called as the scene transitions from the foreground to the background. 47 | // Use this method to save data, release shared resources, and store enough scene-specific state information 48 | // to restore the scene back to its current state. 49 | } 50 | 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Swift知识点/OC到Swift/@UIApplicationMain/test1/test1/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Swift知识点/函数式swift/Map&Filter&Reduce/Map&Filter&Reduce/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // Map&Filter&Reduce 4 | // 5 | // Created by yunna on 2020/4/9. 6 | // Copyright © 2020 yunna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | func incrementArray(xs: [Int]) -> [Int] { 12 | var result: [Int] = [] 13 | for x in xs { 14 | result.append(x + 1) 15 | } 16 | return result 17 | } 18 | 19 | func incrementArray1(xs: [Int]) -> [Int] { 20 | var result: [Int] = [] 21 | for x in xs { 22 | result.append(x * 2) 23 | } 24 | return result 25 | } 26 | 27 | 28 | func incrementArray2(xs: [String]) -> [String] { 29 | var result: [String] = [] 30 | for x in xs { 31 | result.append(x + ",") 32 | } 33 | return result 34 | } 35 | 36 | 37 | func compute(array:[T],transform:(T) -> T) -> [T] { 38 | var result:[T] = [] 39 | for x in array { 40 | result.append(transform(x)) 41 | } 42 | return result 43 | } 44 | 45 | print(compute(array: [1,2,3], transform: {$0 * 2})) 46 | 47 | func double2(array:[Int]) -> [Int] { 48 | return compute(array: array, transform: {$0 * 2}) 49 | } 50 | 51 | 52 | extension Array{ 53 | /// 数组转换,对数字的每一个元素进行转换,然后返回新的数组 54 | /// - Parameter transform:转换类型 55 | func map(transform:(Element) -> T) -> [T] { 56 | var result:[T] = [] 57 | for x in self { 58 | result.append(transform(x)) 59 | } 60 | return result 61 | } 62 | } 63 | 64 | 65 | let arr = [1,2,3] 66 | print(arr.map({$0 * 3})) 67 | 68 | 69 | 70 | let exampleFiles = ["README.md", "HelloWorld.swift", "FlappyBird.swift"] 71 | 72 | func getSwiftFiles(files: [String]) -> [String] { 73 | var result: [String] = [] 74 | for file in files { 75 | if file.hasSuffix(".swift") { 76 | result.append(file) 77 | } 78 | } 79 | return result 80 | } 81 | 82 | print(getSwiftFiles(files: exampleFiles)) 83 | 84 | 85 | extension Array{ 86 | func filter(includeElement:(Element) -> Bool) -> [Element] { 87 | var result:[Element] = [] 88 | for x in self where includeElement(x) { 89 | result.append(x) 90 | } 91 | return result 92 | } 93 | } 94 | 95 | print(exampleFiles.filter(includeElement: {$0.hasSuffix(".swift")})) 96 | 97 | 98 | 99 | func sum(xs: [Int]) -> Int { 100 | var result: Int = 0 101 | for x in xs { 102 | result += x 103 | } 104 | return result 105 | } 106 | 107 | func product(xs: [Int]) -> Int { 108 | var result: Int = 1 109 | for x in xs { 110 | result = x * result 111 | } 112 | return result 113 | } 114 | 115 | func concatenate(xs: [String]) -> String { 116 | var result: String = "" 117 | for x in xs { 118 | result += x 119 | } 120 | return result 121 | } 122 | 123 | 124 | extension Array { 125 | func reduce(initial: T, combine: (T, Element) -> T) -> T { 126 | var result = initial 127 | for x in self { 128 | result = combine(result, x) 129 | } 130 | return result 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /Swift知识点/Swift关键字/尾递归/尾递归.xcodeproj/xcshareddata/xcschemes/尾递归.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 45 | 51 | 52 | 53 | 54 | 60 | 62 | 68 | 69 | 70 | 71 | 73 | 74 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /SwifterProject/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Alamofire (5.4.4) 3 | - BeeHive (1.6.0) 4 | - CryptoSwift (1.4.1) 5 | - DZNEmptyDataSet (1.8.1) 6 | - HomeModule (0.1.0): 7 | - BeeHive (~> 1.6.0) 8 | - JHSwifterSwift (0.1.0) 9 | - Kingfisher (6.3.1) 10 | - Logan (1.2.7): 11 | - Logan/mbedtls (= 1.2.7) 12 | - Logan/mbedtls (1.2.7) 13 | - MBProgressHUD (1.2.0) 14 | - MJRefresh (3.7.2) 15 | - Moya/Core (15.0.0): 16 | - Alamofire (~> 5.0) 17 | - Moya/RxSwift (15.0.0): 18 | - Moya/Core 19 | - RxSwift (~> 6.0) 20 | - ObjectMapper (4.2.0) 21 | - OrderModule (0.1.0): 22 | - BeeHive (~> 1.6.0) 23 | - HomeModule 24 | - Request (0.1.0): 25 | - Moya/RxSwift (~> 15.0.0) 26 | - ObjectMapper (~> 4.2.0) 27 | - RxSwift (6.2.0) 28 | - SQLiteRepairKit (1.2.2): 29 | - WCDBOptimizedSQLCipher (~> 1.2.0) 30 | - SwiftLint (0.44.0) 31 | - ThirdLib (0.1.0): 32 | - CryptoSwift (~> 1.4.1) 33 | - DZNEmptyDataSet (~> 1.8.1) 34 | - Kingfisher (~> 6.3.1) 35 | - Logan (~> 1.2.7) 36 | - MBProgressHUD (~> 1.2.0) 37 | - MJRefresh (~> 3.7.2) 38 | - WCDB.swift (~> 1.0.8.2) 39 | - WCDB.swift (1.0.8.2): 40 | - SQLiteRepairKit (~> 1.2.0) 41 | - WCDBOptimizedSQLCipher (~> 1.2.0) 42 | - WCDBOptimizedSQLCipher (1.2.1) 43 | 44 | DEPENDENCIES: 45 | - BeeHive 46 | - HomeModule (from `Modules/HomeModule`) 47 | - JHSwifterSwift (from `Modules/JHSwifterSwift`) 48 | - OrderModule (from `Modules/OrderModule`) 49 | - Request (from `Modules/Request`) 50 | - SwiftLint 51 | - ThirdLib (from `Modules/ThirdLib`) 52 | 53 | SPEC REPOS: 54 | trunk: 55 | - Alamofire 56 | - BeeHive 57 | - CryptoSwift 58 | - DZNEmptyDataSet 59 | - Kingfisher 60 | - Logan 61 | - MBProgressHUD 62 | - MJRefresh 63 | - Moya 64 | - ObjectMapper 65 | - RxSwift 66 | - SQLiteRepairKit 67 | - SwiftLint 68 | - WCDB.swift 69 | - WCDBOptimizedSQLCipher 70 | 71 | EXTERNAL SOURCES: 72 | HomeModule: 73 | :path: Modules/HomeModule 74 | JHSwifterSwift: 75 | :path: Modules/JHSwifterSwift 76 | OrderModule: 77 | :path: Modules/OrderModule 78 | Request: 79 | :path: Modules/Request 80 | ThirdLib: 81 | :path: Modules/ThirdLib 82 | 83 | SPEC CHECKSUMS: 84 | Alamofire: f3b09a368f1582ab751b3fff5460276e0d2cf5c9 85 | BeeHive: 64c01ddec33b9ef8813701e075eeb732327d0f75 86 | CryptoSwift: 0bc800a7e6a24c4fc9ebeab97d44b0d5f73a78bd 87 | DZNEmptyDataSet: 9525833b9e68ac21c30253e1d3d7076cc828eaa7 88 | HomeModule: 893ec02b734fb237745452d4d3ccbfbf24b84beb 89 | JHSwifterSwift: fd2bea9691f620f36044c641e02cf5043ac006f5 90 | Kingfisher: 016c8b653a35add51dd34a3aba36b580041acc74 91 | Logan: d7e508f88d596b186e9cdcc0cf35b45c89bbc22f 92 | MBProgressHUD: 3ee5efcc380f6a79a7cc9b363dd669c5e1ae7406 93 | MJRefresh: 30997d30b347c8e9508a4db11e3a690da0c9b85a 94 | Moya: 138f0573e53411fb3dc17016add0b748dfbd78ee 95 | ObjectMapper: 1eb41f610210777375fa806bf161dc39fb832b81 96 | OrderModule: 3780c417f7248f051a65fd942cde768c2375f0a3 97 | Request: 58c35e8fa82d4e6c2e3d06e0cb246536b3abd5d4 98 | RxSwift: d356ab7bee873611322f134c5f9ef379fa183d8f 99 | SQLiteRepairKit: 35aaae5a8838adb85f5b1eb4d796055be6060a4b 100 | SwiftLint: e96c0a8c770c7ebbc4d36c55baf9096bb65c4584 101 | ThirdLib: 827450f9b5a8fe977d3589dca28852a2481430f8 102 | WCDB.swift: 05d509d7a0e60fb6e11c34eb7e4027c0fab5849f 103 | WCDBOptimizedSQLCipher: baf44493b0c7a3d49e97bc5b64a3856f6428ddd1 104 | 105 | PODFILE CHECKSUM: ee1649ebd3119687ec4fe438425ca64b3bb6b93d 106 | 107 | COCOAPODS: 1.11.1 108 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Swift学习 2 | 3 | 使用BeeHive实现一个组件化方案,封装了各种工具。欢迎相互交流 4 | 5 | 项目包含5个组件 6 | - 1、ThirdLib:各种第三方封装 7 | - Crypto:加密 8 | - DB:基于WCDB的封装 9 | - HUD:MBProgressHUD封装 10 | - Log:基于Logan的封装 11 | - UIImageView+Kingfisher 12 | - UIScrollView+Extension 13 | - 添加刷新 14 | - 空白页 15 | - 2、Request:Moya/RxSwift/ObjectMapper封装 16 | - 直接返回model 17 | - 添加数据缓存 18 | - 网络日志打印 19 | 20 | - 3、JHSwifterSwift:各种小工具 21 | - 4、HomeModule:业务逻辑 22 | - 5、OrderModule:业务逻辑 23 | 24 | 25 | 26 | - [知识点](https://github.com/SunshineBrother/SwiftTools/blob/master/知识点.md) 27 | - [小工具](https://github.com/SunshineBrother/SwiftTools/blob/master/tools.md) 28 | 29 | 30 | 31 | # 新项目开始前的思考 32 | 33 | ## 第三方库 34 | 35 | - 代码规范 36 | - 代码规范:[SwiftLint](https://github.com/realm/SwiftLint) 37 | - 格式化代码:[SwiftFormat](https://github.com/nicklockwood/SwiftFormat) 38 | - 网络 39 | - 网络请求:Moya+RXSwift+ObjectMapper 40 | - json转model:ObjectMapper、HandyJSON、KakaJSON 41 | - 快速的格式化JSON数据并转换生成对应的模型类属性:[JSONConverter](https://github.com/DevYao/JSONConverter) 42 | - json数据处理:[SwiftyJSON](https://github.com/SwiftyJSON/SwiftyJSON) 43 | - 网络图片:[Kingfisher](https://github.com/onevcat/Kingfisher) 44 | - [Reachability.swift](https://github.com/ashleymills/Reachability.swift) - 用于替换苹果的 Reachability 类,可以方便地检测当前是否联网以及具体的联网状态. 45 | - UI 46 | - 布局:[SnapKit](https://github.com/SnapKit/SnapKit) 47 | - 刷新:[MJRefresh](https://github.com/CoderMJLee/MJRefresh) 48 | - 加载框:[MBProgressHUD](https://github.com/jdg/MBProgressHUD) 49 | - 富文本:[ActiveLabel.swift](https://github.com/optonaut/ActiveLabel.swift) 50 | - 键盘:[IQKeyboardManager](https://links.jianshu.com/go?to=https%3A%2F%2Fgithub.com%2Fhackiftekhar%2FIQKeyboardManager) 51 | - 动画:[lottie-ios](https://github.com/airbnb/lottie-ios) 52 | - 空页面:[DZNEmptyDataSet](https://link.zhihu.com/?target=https%3A//github.com/dzenbot/DZNEmptyDataSet) 53 | - 数据存储 54 | - 小数据:[SwiftyUserDefaults](https://github.com/sunshinejr/SwiftyUserDefaults) 55 | - 数据库: 56 | - [WCDB](https://github.com/Tencent/wcdb) 57 | - [GRDB.swift](https://github.com/groue/GRDB.swift) 58 | - [SQLite.swift](https://github.com/stephencelis/SQLite.swift) 59 | - 资源管理 60 | - [R.swift](https://github.com/mac-cain13/R.swift):优雅安全的方式使用资源文件 61 | - 安全 62 | - [CryptoSwift](https://github.com/krzyzanowskim/CryptoSwift) 63 | - 工具 64 | - [SwifterSwift](https://github.com/SwifterSwift/SwifterSwift) 65 | - 日志 66 | - [Logan](https://github.com/Meituan-Dianping/Logan):美团的大前端日志库 67 | - 埋点 68 | - [神策](https://manual.sensorsdata.cn/sa/latest/page-1573910.html) 69 | - 组件化 70 | - [CTMediator](https://github.com/casatwy/CTMediator) 71 | - [ BeeHive](https://github.com/alibaba/BeeHive) 72 | 73 | 74 | 75 | 76 | ## 需要注意的问题 77 | 78 | - 国际化问题 79 | - 安卓 iOS 前端统一资源 80 | - 路由管理 81 | - 是否有节假日换皮肤的需求 82 | - 黑暗模式是否是配 83 | - tabbar和navigationbar问题 (是否用,待考虑) 84 | - [ESTabBarController](https://github.com/eggswift/ESTabBarController) 85 | - [RTRootNavigationController](https://github.com/rickytan/RTRootNavigationController) 86 | - 资源管理(考虑) 87 | - 文字(大小,类型)资源:统一格式,json读取 88 | - color资源:统一格式,json读取 89 | - 图片资源:json读取 90 | - 架构模式(MVC) 91 | - Server层:api+server+json转model 92 | - Model层 93 | - view层:view层仅仅负责布局,事件处理可以通过代理交给controller层处理 94 | - controller 95 | - 给view赋值 96 | - 处理响应事件 97 | - 处理一些业务逻辑 98 | - 基类放到哪里 99 | - BaseViewConroller 100 | - BaseWebViewController 101 | 102 | 103 | 104 | ## 架构 105 | 106 | ### 基础模块 107 | 108 | - 1、tabbarModules(待考虑) 109 | 110 | - 2、navigationBarModules(待考虑) 111 | 112 | - 3、WrappersModules 包装整个项目(待考虑:是单独的module还是直接放到主项目里面) 113 | 114 | - 4、FoundationModules 基于系统库封装 115 | 116 | - 5、widgetModules 一些小组建的封装 117 | 118 | - 6、sdkModules 119 | 120 | 121 | 122 | ### 业务模块 123 | 124 | - 1、DataCenterModules 数据中心 125 | - 待考虑:这个数据中心我们是做成**集约型还是离散型** 126 | - 集约型:作为一个modules,其他的读取这个modules 127 | - 离散型:每个modules自己存储自己数据中心,注册的时候需要赋值,好处:每一个模块都可以单独运行,不需要依赖这个独立的数据中心 128 | - 静态数据 129 | - color资源 130 | - 文字(大小,类型)资源 131 | - 动态数据 132 | - userId 133 | - token 134 | - mobile 135 | - 2、LoginModule 136 | - 3、HomeModule 137 | - 4、OrderModule 138 | - 5、PayModule 139 | - 6、AnalyseModule埋点 140 | - 7、WebViewModule等等 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | --------------------------------------------------------------------------------