# Swift **Repository Path**: SwiftLanguage/Swift ## Basic Information - **Project Name**: Swift - **Description**: Swift一些之类整理 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-01-24 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Swift Swift一些之类整理 ## Swift语法 1. Swift对比Objective-C系列(持续更新中……) >http://www.cocoachina.com/industry/20140605/8686.html 2. 编译性语言和解释性语言的区别 >http://blog.csdn.net/zhu_xun/article/details/16921413 3. 评价Swift >https://www.zhihu.com/question/24002984 4. Swift学习之和Objective-C的联系与区别 >http://blog.csdn.net/yxys01/article/details/51829182 ## 《The Swift Programming Language》中文版 2.x版本的 >https://numbbbbb.gitbooks.io/-the-swift-programming-language-/content/chapter1/chapter1.html ## swift4.x 官方链接 >https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/index.html 2. 最全的 Swift 4 新特性解析 >http://liuduo.me/2017/06/09/Whats_new_in_swift_4_completely/ ## swift中文教程翻译 >https://www.cnswift.org/ >http://www.swift51.com/swift.html ## Swift 语言指南 >https://github.com/ipader/SwiftGuide >http://dev.swiftguide.cn/ ## Swift 示例demo >https://github.com/matteocrippa/awesome-swift >https://github.com/allenwong/30DaysofSwift >https://github.com/Lax/iOS-Swift-Demos 提醒app >https://github.com/rizal72/iContactU ## Swift-project-template >https://github.com/artemnovichkov/swift-project-template 2. >https://github.com/kongyixueyuan/30DaysofSwift ## iOS Examples 1. iOS-11-By-Example >https://github.com/artemnovichkov/iOS-11-by-Examples 2. iOS-10-Sample >https://github.com/shu223/iOS-10-Sampler 3. iOS-9-Sample >https://github.com/shu223/iOS-9-Sampler 4. iOS-8-Sample >https://github.com/shu223/iOS8-Sampler ------------------------------------------------------------------------------------------------- # Swift使用记录 ## 编译标记 1. 编译标记 >http://swifter.tips/param-mark/ 2. 将Swift项目中的TODO显示为Warning >http://chisj.github.io/blog/2016/03/07/jiang-swiftxiang-mu-zhong-de-todoxian-shi-wei-warning/ ## 内存管理,WEAK 和 UNOWNED [unowned self] weak等使用 >http://swifter.tips/retain-cycle/ ## IBInspectable和IBDesignable >http://zhangbuhuai.com/ibinspectable-and-ibdesignable/ ## Swift中的属性学习 >http://codebuild.me/2015/05/08/Swift%E4%B8%AD%E7%9A%84%E5%B1%9E%E6%80%A7%E5%AD%A6%E4%B9%A0/ ## Swift - 访问控制(fileprivate,private,internal,public,open) >http://www.hangge.com/blog/cache/detail_524.html ## Swift中重写重载构造(初始化)方法 >https://www.jianshu.com/p/5c133b123c74 iOS: 聊聊 Designated Initializer(指定初始化函数)与便利构造初始化函数 >https://www.cnblogs.com/smileEvday/p/designated_initializer.html ## 数组判断和使用 >https://stackoverflow.com/questions/27588964/check-if-optional-array-is-empty ## 类调用问题 ``` 1.Bundle调用 Bundle.main.path() 2.自定义类 JSONHandle调用 JSONHandle().changeData2Json() 为什么Bundle调用不用加(),JSONHandle类调用要加() bundle中的main是来方法 定义如下: class var main: Bundle{} JSONHandle中的changeData2Json是实例方法 具体查看: http://www.swift51.com/swift4.0/chapter2/11_Methods.html ``` ## swift工程中使用OC库,如何让swift类中调用的oc方法也显示成swift的方法展示 首先在swift类文件的顶部中一定要引用 ``` 例如 import 'MJRefresh' 而在 -Bridging-Header.h中 #import 无效 ``` ## OC、SWift混编 在Swift项目中使用OC,在OC项目中使用Swift >http://kittenyang.com/swiftandoc/ ## Swift中的可选类型(Optional Type) ``` value of optional type 'string ' not unwrapped did you mean to use ' ' or ' ' 经常报错的具体详解 ``` >http://www.cocoachina.com/swift/20160810/17330.html ## guard的使用记录 ``` //以下语句可以理解为: 如果self?.index,self?.size有值,那么我们赋值给index,size,没有的话直接返回,增加了代码判断 guard let index = self?.index, let size = self?.size else{ return } self.requestSortList(with:0, pageIndex:index, pageSize: size) ``` ## lazy使用 > ``` 延迟加载主要有以下两个使用的场景: 属性的初始值依赖于其他的属性值,只有其他的属性值有值之后才能得出该属性的值。 属性的初始值需要大量的计算。 ``` ``` lazy var names: NSArray = { let names = NSArray() print("只在首次访问输出") return names }() ``` ------------------------------------------------------------------------------------------------- # 开发中借鉴Demo或者文章 1. UICollectView 纯代码实现 >http://blog.csdn.net/u010586842/article/details/48209153 >https://www.oudahe.com/p/24179/ 最简单的demo >https://www.jianshu.com/p/3c95eacbae54 ------------------------------------------------------------------------------------------------- 疑惑: 1. delegate和extension 的区别 类构造器怎么写 2. init 和 类方法的区别 ------------------------------------------------------------------------------------------------- # swift blog和资料 1.内存管理,WEAK 和 UNOWNED >http://swifter.tips/ 2.Swift4语法极简手册 — ARC >https://lingenliu.com/2017/08/01/the-simple-book-of-swift4-ARC/