Last Updated: February 25, 2016
·
1.138K
· kkoval

Swift Clean Code

Make Clean code by splitting your code into Extensions and Nested types .

Read more here - Swift clean Lazy Properties

Save this code snippet to Xcode

Code Snippet

// MARK: - Factory
private extension <#Class#> {
  private class Factory {
    class func <#funcName#>() -> <#ReturnType#> {
      return <#code#>
    }
  }
}

Example

class ArmaturListViewModel {  
  var names = Factory.names()
}

private extension ArmaturListViewModel {

  private class Factory {
    class func names() -> [String] {
      return [
        "Petter",
        "Simon",
        "Anna"]
    }
  }