回顧即開始html
.gitignore
: Swift or Objective-Csudo 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 │ ├─ Info.Plist │ ├─ BuildConfigs │ └─ ··· ├─Sources │ ├─ Modules │ ├─ MyModule │ │ │ ├─ Models │ │ │ ├─ Views │ │ │ └─ Controllers (or ViewModels) │ │ └─ ··· │ ├─ Stores │ ├─ Helpers │ ├─ Utilities │ ├─ Extentsions │ ├─ Mediator │ ├─ Ventors │ └─ ··· ├─Tests └─ ··· 複製代碼
// 全局常量建議採用 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) } } } 複製代碼
Alamofire 網絡庫react
Moya 基於Alamofire 封裝的網絡抽象層ios
Reachability.swift 用於網絡情況檢查git
R.swift 自動將各類資源強類型化github
RxSwift 響應式編程框架 by ReactiveX.io編程
LayoutKit 高性能視圖佈局庫bootstrap
Kingfisher 輕量級圖片下載緩存庫swift
NSLogger 便捷日誌工具api
FLEX/DoraemonKit 應用內 Debug 工具庫
struct
+ Codable
Apple 文檔let fooViewController = FooViewController(withViewModel: fooViewModel) 複製代碼
func fetchGigs(for artist: Artist) -> Observable<[Gig]> { // ... } 複製代碼
.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
加密儲存敏感數據
https
TLS 加密傳輸UITextField
用於密碼等敏感信息輸入時設置secureTextEntry
爲 true
applicationDidEnterBackground
Exception
斷點歡迎指正共建與獲取最新狀態:Github 倉庫 - iOS-Practice-Checklist