因为PHP后端传送过来的接口并没有按照严格的Swagger文档来传值,所以最近对后台制定了相关的JSON规范。良好的规范有助于前端解码JSON,用Swift自带的Codable协议来解码JSON。
Magical Error Handling in Swift
以下是阅读Ray Wenderlich的笔记。原文链接 这个简单的例子,完美把很多的知识点都说到了。Swift 的引入可以让我们不再写类似金字塔的错误处理逻辑,更方便调试。
Pattern Matching in Swift
原文链接 It’s the perfect pattern match! Pattern matching is one of the most powerful features of any programming language, because it enab...
Pattern matching
来至于的《Swift Apprentice》中的章节的笔记。 https://www.raywenderlich.com/134844/pattern-matching-in-swift 匹配元组 Switch可以匹配多种情况,可以匹配范围。
Protocol
Protocol is name type, structs ,classes, and enums also name type. . Swift中默认所有的方法都是必须实现是的 协议可以被、、所遵守。 协议里的方法不能包含默认值。
Singleton
该文讲述了三种方法来创建单例, 各种方法的优点以及缺点,该文也介绍了另外一篇文章单例的Are Singletons Bad。 原文地址 The singleton pattern is a widely used design pattern in software d...
String
多行字符串 如果你只是想换行让文本更易读,而不是想在字符串中真正的换行可以在要换行的地方加上 通常在OC中我们访问相应位置的字符使用Int类型像数组一样就可以访问,但是针对于特别的情况OC中就显得力不从心,例如像e带音节,单独的e带音节是233,但是也有分开单独e字幕加...
UIStackView Tutorial Introducing Stack Views
We’ve all been there. There’s a new requirement and you need to add or remove a view at runtime, and also need to reposition adjacent v...
Swift Tip: Notifications
重构键盘监听代码,通过创建结构体,来简化代码。这样也能保证整个项目中都共享一套键盘监听的数据逻辑。 Swift Tip: Notifications Posted on July 3rd 2018 In Episode 107 of our Swift Talk ser...
Swift Tutorial/Initialization In Depth Part 1
在类没有完全初始化之前,你不能使用他,使用他包含访问属性、设置属性、调用方法。 本篇主要讲解结构体的初始化,结构体会在没有自定义初始化方法的情况下自动为所有的函数创建默认的初始化方法,但是如果你自己提供了初始化方法,那么自动的初始化方法就会失效,但是也可以把自定义的初始...