1οΈβ£ Naming
- λͺ¨νΈν¨μ νΌνκΈ° μν΄ λ³μλ ν¨μκ° νλ μΌμ λͺ¨λ λ¨μ΄λ₯Ό ν¬ν¨ν΄μΌν¨
extension List {
public mutating func remove(at position: Index) -> Element
}
employees.remove(at: x)
- μ€μν μ λ³΄λ§ λ€μ΄κ°μΌνκ³ μ€λ³΅μ΄λ λΆνμν μ λ³΄κ° μ΄λ¦μ λ€μ΄κ°λ©΄ μλ¨
public mutating func remove(_ member: Element) -> Element?
allViews.remove(cancelButton)
- νμ
μ΄ μ΄λ¦μ λ€μ΄κ°λ©΄ μλκ³ , μν μ΄ μ΄λ¦μ λ€μ΄κ°μΌν¨
var greeting = "Hello"
protocol ViewController {
associatedtype ContentView : View
}
class ProductionLine {
func restock(from supplier: WidgetFactory)
}
- νλ‘ν μ½ μ΄λ¦μ΄ μν μ΄ λλ κ²½μ° νλ‘ν μ½μ΄λ¦μ Protocolμ μΆκ°νμ¬ μΆ©λμ νΌν΄μΌν¨
protocol Sequence {
associatedtype Iterator : IteratorProtocol
}
protocol IteratorProtocol { ... }
- λ©μλλ₯Ό μ μΈνλκ³³κ³Ό μ¬μ©νλ κ³³μμ 맀κ°λ³μμ μν μ λͺ
νν λνλΌ μ μμ΄μΌν¨
func addObserver(_ observer: NSObject, forKeyPath path: String)
grid.addObserver(self, forKeyPath: graphics)
2οΈβ£ Strive for Fluent Usage
Tip
- initailize, get, set, make λμ generate, configureλ₯Ό μ¬μ©
μΆμ²π
πApple Docs: api-design-guidelines