作者丨Binboy_王兴彬
来源丨知识小集
回顾即开始
.gitignore
: sudo gem install cocoapods # 安装
pod init # 初始化创建 Podfile
pod install/update # 安装/更新依赖
brew install carthage # 安装
carthage bootstrap/update # 安装或更新依赖
AwesomeProject
├─ Assets
│ ├─ Info.Plist
│ ├─ Localizable.strings
│ ├─ R.generated.swift # 可选,R.swift 生成
│ ├─ LaunchScreen.storyboard
│ ├─ Assets.xcassets
│ ├─ ProjectName.entitlements
│ ├─ BuildConfigs
│ └─ ···
├─Sources
│ ├─ Modules
│ ├─ MyModule
│ │ │ ├─ Models
│ │ │ ├─ Views
│ │ │ └─ Controllers or ViewModels
│ │ └─ ···
│ ├─ Stores
│ ├─ Helpers
│ ├─ Utilities
│ ├─ Extentsions
│ ├─ Mediator
│ ├─ Ventors
│ └─ ···
├─Tests
└─ ···
• WWDC 404 - New Localization Workflows in Xcode 10 https://developer.apple.com/videos/play/wwdc2018/404/
• WWDC 401 - Localizing with Xcode 9 https://developer.apple.com/videos/play/wwdc2017/401
• WWDC 201 - Internationalization Best Practices https://developer.apple.com/videos/play/wwdc2016/201
// 全局常量建议采用 Enum 定义
enum Constants {
static let myConstant = "Just a constant"
}
enum Apprearance {
enum Sizes {
static let gutter: CGFloat = 15
static let cardGutter: CGFloat = 8
···
}
enum Color {
static let primaryColor = UIColor red: 0.22, green: 0.58, blue: 0.29, alpha: 1.0
static let secondaryColor = UIColor.lightGray
static let background = UIColor.white
enum Red {
// 可视化颜色
static let medium = #colorLiteral red: 0.22, green: 0.58, blue: 0.29, alpha: 1.0
static let light = #colorLiteral red: 0.22, green: 0.58, blue: 0.29, alpha: 1.0
}
}
}
• git-flow 的工作流 - Tower https://www.git-tower.com/learn/git/ebook/cn/command-line/advanced-topics/git-flow
• gitflow-avh 拓展 https://github.com/petervanderdoes/gitflow-avh
struct
+ Codable
Apple 文档 • Apple 文档 - NSLayoutAnchor https://developer.apple.com/documentation/uikit/nslayoutanchor
• WWDC 220 - High Performance Auto Layout https://developer.apple.com/videos/play/wwdc2018/220
• WWDC 218 - Mysteries of Auto Layout, Part 1 https://developer.apple.com/videos/play/wwdc2015/218
• WWDC 219 - Mysteries of Auto Layout, Part 2 https://developer.apple.com/videos/play/wwdc2015/219
• 8 Patterns to Help You Destroy Massive View Controller http://khanlou.com/2014/09/8-patterns-to-help-you-destroy-massive-view-controller/
let fooViewController = FooViewController withViewModel: fooViewModel
func fetchGigs for artist: Artist -> Observable<Gig> {
// ...
}
• Apple 文档 - Core Data https://developer.apple.com/documentation/coredata
• WWDC 224 - Core Data Best Practices https://developer.apple.com/videos/play/wwdc2018/224/
.pdf
矢量图//MARK:
+ Extension
分组结构化代码import SomeExternalFramework
class FooViewController : UIViewController {
let foo: Foo
private let fooStringConstant = "FooConstant"
private let floatConstant = 1234.5
// MARK: Lifecycle
// Custom initializers go here
···
}
// MARK: View Lifecycle
extension FooViewController {
override func viewDidLoad {
super.viewDidLoad
// ...
}
}
// MARK: Layout
extension FooViewController {
private func makeViewConstraints {
// ...
}
}
// MARK: User Interaction
extension FooViewController {
func foobarButtonTapped {
// ...
}
}
// MARK: FoobarDelegate
extension FooViewController: FoobarDelegate {
func foobar foobar: Foobar, didSomethingWithFoo foo: Foo {
// ...
}
}
// MARK: Helpers
extension FooViewController {
private func displayNameForFoo foo: Foo {
// ...
}
}
UserDefault
或 CoreData
等非加密持久化方式KeyChain
加密储存敏感数据• Apple 文档 - Storing Keys in the Keychain https://developer.apple.com/documentation/security/certificate_key_and_trust_services/keys/storing_keys_in_the_keychain
• KeychainAccess https://github.com/kishikawakatsumi/KeychainAccess
https
TLS 加密传输UITextField
用于密码等敏感信息输入时设置secureTextEntry
为 true
• `applicationDidEnterBackground`
• Product → Analyze
• 开启 `Exception` 断点
• Reveal http://revealapp.com/ 视图调试
• Apple 帮助 - Instruments https://help.apple.com/instruments/mac
推荐↓↓↓
长
按
关
注
👉【16个技术公众号】都在这里!
涵盖:程序员大咖、源码共读、程序员共读、数据结构与算法、黑客技术和网络安全、大数据科技、编程前端、Java、Python、Web编程开发、Android、iOS开发、Linux、数据库研发、幽默程序员等。