βœ‹ βœ‹ βœ‹ The super easy and generic builder pattern. It's easy if you try πŸ’ͺ.

Overview

Builder

contributions welcome Swift Version CocoaPods Build Status Carthage compatible

βœ‹ βœ‹ βœ‹ The super easy and generic builder pattern. It's easy if you try πŸ’ͺ .

Introduction

Initialize UIView build set its properties. πŸ‘ πŸ‘

let label:UIView = .build{
  $0.backgroundColor = .red
  $0.clipsToBounds = true
}

πŸ‘‡ πŸ‘‡ This is equivalent to: πŸ‘‡ πŸ‘‡

let label: UIView = {
  let view = UIView()
  view.backgroundColor = .red
  view.clipsToBounds = true
  return view
}()

Tips and examples

  • You can use build to all of NSObject subclasses.
    let view = UIView.build { // Example 1
      $0.color = .red
    }
     let view:UIView = .build { (view) in // Example 2
        view.color = .red
     }
     let view:UIView = .build { // Example 2
       $0.color = .red
     }
  • You can use build to all of class and structure. Just make extensions. Init implementation is required for the class, not required for the structure
    extension UserType: EKBuilder {}
    
    let instance:UserType = .build{
      $0.value = "it's easy if you try!"
    }
  • Example: Here's an example usage in an UIViewController subclass.
      class Tesla: EKBuilder {
             var type:String!
             var count:Int!
             required init() {}
      }
      
      struct Audi:EKBuilder {
             var type:String!
             var count:Int!
      }
     
     final class ViewController: UIViewController {
     
       let tesla:Tesla = .build {
         $0.type = "Model X"
         $0.count = 10
       }
     
       let audi = Audi.build {
          $0.type = "R8"
          $0.count = 10
       }
     
       override func viewDidLoad() {
         super.viewDidLoad()
         print(tesla.type, tesla.count)
         print(audi.type, audi.count)
       }
     
     }

Installation

CocoaPods

Add the following entry to your Podfile:

pod 'EKBuilder'

Then run pod install.

Don't forget to import EKBuilder in every file you'd like to use Hero.

Carthage

Add the following entry to your Cartfile:

github "erikkamalov/EKBuilder"

Then run carthage update.

If this is your first time using Carthage in the project, you'll need to go through some additional steps as explained over at Carthage.

License

EKBuilder is under MIT license. See the LICENSE file for more info.

You might also like...
A simple menubar app can give you quick access to some macOS functions
A simple menubar app can give you quick access to some macOS functions

OneClick This simple menubar app can give you quick access to some macOS functio

Have you ever wanted to just throw your optional like a table?

JebStolem Have you ever wanted to just throw your optional like a table? Or mayb

This is an iOS Safari Extension Sample that adds a "Develop menu" to Safari on iOS to allow you to analyze websites.

Develop Menu for Mobile Safari This is an iOS Safari Extension that adds a "Develop menu" to Safari on iOS to allow you to analyze websites. This is a

You can touch My Swift, MapKit, UX skills! :D
You can touch My Swift, MapKit, UX skills! :D

What is it? πŸ™‹πŸ» It's a pet project which has been developed as a code challenge. It's written purely in Swift without using 3rd party frameworks. Wha

ChidoriMenu - An easy way to add menus visually similar to iOS 14's Pull Down and Context Menus but with some added benefits
ChidoriMenu - An easy way to add menus visually similar to iOS 14's Pull Down and Context Menus but with some added benefits

ChidoriMenu 🐦 ⚑️ An easy way to add popover menus visually similar to the Conte

Easy usage SFSymbols. If symbol not available, compiler will show warning.
Easy usage SFSymbols. If symbol not available, compiler will show warning.

SFSymbols Wrapper of SFSymbols. You choose the icon and what style to draw it in. You can specify the font with which to draw the icon. If the symbol

iOS native app demo with Xcode and Swift using MVVM architecture and Apple's Combine framework for functional reactive programming, all with UIKit
iOS native app demo with Xcode and Swift using MVVM architecture and Apple's Combine framework for functional reactive programming, all with UIKit

iOS (Swift 5): MVVM test with Combine and UIKit MVVM and functional reactive programming (FRP) are very used in iOS development inside companies. Here

Explanations and samples about the Swift programming language
Explanations and samples about the Swift programming language

About Swift Contents Explanations and samples about: Swift Programming Language Swift Standard Library Target audience Developers familiar with object

πŸ‘¨β€πŸ’»Watch the latest and greatest conference videos on your Mac
πŸ‘¨β€πŸ’»Watch the latest and greatest conference videos on your Mac

Conferences.digital is the best way to watch the latest and greatest videos from your favourite developer conferences for free on your Mac. Either sea

Releases(1.0.2)
Owner
E K
❀️Open Source & ❀️Experiment UI/UX | Swift Developer Tools & Frameworks. Server-Side Vapor
E K
HotCoffee is learning project with MVVM, Generic,Swift 5, TableView

HotCoffee A simple Coffee Ordering app built using TableView, MVVM design pattern and Swift5. Tools Xcode Version 13.2.1 Framework -UIKit Architecture

Ghullam Abbas 2 Aug 26, 2022
Exemplify a LazyVGrid in SwiftUI in a MVVM pattern with Mock Data and images in assets.

SwiftUI-LazyVGrid Exemplify a LazyVGrid in SwiftUI in a MVVM pattern with Mock Data and images in assets. Screenshots Samples IP & Credits All those b

Ethan Halprin 3 Aug 9, 2022
Cryptocurrency price checker, build with UIKit and MVC + Delegate pattern.

Coin Check Cryptocurrency price checker. The app fetch from CoinAPI.io the latest coin prices, build with UIKit and MVC + Delegate pattern. Features S

Anibal Ventura 0 Jan 10, 2022
ProductListSwiftUI - SwiftUI Project to fetch product list using the fakestoreapi and the MVVM architectural pattern

ProductListSwiftUI SwiftUI Project to fetch product list using the fakestoreapi

Vitalii Shapovalov 4 Sep 16, 2022
NewsAppMVVM - A Swift iOS App created to practice MVVM Design Pattern

NewsAppMVVM A Swift iOS App created to practice MVVM Design Pattern. This app re

Jorge Roberto 1 Jan 3, 2022
A sample project exploring MVVM pattern with SwiftUI/Combine, using Unsplash API (via Picsum.photos API)

CombineUnsplash A sample project exploring MVVM pattern with SwiftUI/Combine, using Unsplash API (via Picsum.photos API) with detail example. Resource

Vinh Nguyen 26 Dec 13, 2022
Aplikasi iOS Berita Internasional dengan SwiftUI, API dari newsapi.org, MVVM Design Pattern, dan Paw

iNews iNews adalah aplikasi iOS Berita Internasional yang datanya didapatkan dari News API. Dibuat menggunakan SwiftUI, MVVM Design Pattern, dan Paw.

DK 8 Aug 1, 2022
A travel guide app that implements MVVM design pattern, using mock API.

✈️ Travel Guide App ?? A travel guide app that implements MVVM design pattern, using mock API. ✨ Features ?? Project Features Written in Swift Impleme

Burak Ertaş 4 Nov 7, 2022
A UIKit based geotagging app that let's you save places you have visited with images.

My Locations Getting Started Using Core Location A CLLocationManager() performs the location updating It sends its updates to its delegate, so make su

Xiao Quan 全笑 0 Jan 4, 2022
A blog project where you can write your articles, upload photos, categorize them, and add them to your favorites

A blog project where you can write your articles, upload photos, categorize them, and add them to your favorites. The aim of the project is to learn the use of Core Data.

Cem 7 Mar 21, 2022