• Stars
    star
    161
  • Rank 233,470 (Top 5 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 8 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Type-safe and constructor injectable InterfaceBuilder protocols.

Instantiate

Build Status Carthage compatible

Type-safe and constructor injectable InterfaceBuilder protocols.

Summary

Storyboard and Nib is not type safe, if you use UIStoryboard or UINib, your code would be get some gloom. Instantiate take type-safe protocols for Storyboard and Nib. Lets' improve our code with type-safe protocols!

as is

let storyboard = UIStoryboard(name: "ViewController", bundle: Bundle.main)
let vc = storyboard.instantiateInitialViewController() as! ViewController
vc.inject([1, 2, 3])

to be

import Instantiate
import InstantiateStandard
extension ViewController: StoryboardInstantiatable {}
let vc = ViewController(with: [1, 2, 3])

Protocols

StoryboardInstantiatable

Supports using viewController with Storyboard. Implement StoryboardInstantiatable at your viewController class, then you can use ViewController(with: Dependency).

NibInstantiatable

Supports using view with Nib. Implement NibInstantiatable at your view class, then you can use View(with: Dependency).

NibInstantiatableWrapper

Supports using view implements NibInstantiatable in other InterfaceBuilder. NibInstantiatableWrapper supports workaround. Make new UIView subclass, and implement NibInstantiatableWrapper, call loadView on init(coder:) and prepareForInterfaceBuilder. http://stackoverflow.com/questions/27807951/how-to-embed-a-custom-view-xib-in-a-storyboard-scene

Reusable

Supports UITableViewCell / UICollectionViewCell reuse features. Implement Reusable, then you can dequeue cell using Cell.dequeue(from: Parent, for: IndexPath, with: Dependency).

InstantiateStandard

StoryboardType and NibType required static var storyboard or static var nib. You need to write these values on own class, it is troublesome... Many developer define StoryboardName is same of ClassName, and if you are also, you can use InstantiateStandard. This libraly add default implementation of StoryboardType, NibType, and Reusable.

Instalation

Carthage

github "tarunon/Instantiate"

Pods

pod 'Instantiate'

Swift Package Manager

Select Xcode menu File > Swift Packages > Add Package Dependency... and enter repository URL with GUI.

Repository: https://github.com/tarunon/tarunon/Instantiate

Requirement

Platform Version
iOS 9.0+
macOS 10.11+
tvOS 9.0+
Swift 4.0+

More Repositories

1

XCTAssertNoLeak

Provides assert function that check memory leak in Swift.
Swift
363
star
2

XCTAssertAutolayout

Provides assert function that check autolayout error in Swift
Swift
302
star
3

Cuculus

A library for Swift Function Hooking.
Swift
84
star
4

UIViewBuilder

Generate UIKit (not SwiftUI) components from FunctionBuilder.
Swift
73
star
5

AnyObjectConvertible

Convert your own struct/enum to AnyObject easily.
Swift
62
star
6

try-erasure

Swift Type-Erasure implementation and benchmark
Swift
60
star
7

AutoSnapping

Auto snapping when scroll decelerating in UITableView or UICollectionView
Swift
32
star
8

Barrel

A simple type-safe library for NSPredicate and NSExpresion.
Swift
21
star
9

ios_boilerplate

Swift
19
star
10

XWorkarounds

Workaround for iPhoneX/iOS11
Swift
18
star
11

Illuso

JSON encoder for Swift.
Swift
12
star
12

JS2ObjC

Connect Javascript and Objective-C at iOS application.
Objective-C
11
star
13

Buildable

Create own FunctionBuilder from Protocol
Swift
10
star
14

Covariancable

Add covariance/contravariance feature on your type-erasure.
Swift
6
star
15

Hiyoko

http://www.hiyoko.co.jp, It's a sweets in Fukuoka. But this repo maybe become twitter app for iOS.
Swift
5
star
16

NotificationKit

A simple type-safe NSNotificationCenter library
Swift
5
star
17

mstdn

mastodonクライアントアプリ開発RTA
Swift
4
star
18

RxInstantiate

Protocols and default implementation of RxSwift, RxDataSources, and Instantiate
Swift
4
star
19

enum-convertible

Protocols for enum abstraction.
Swift
3
star
20

RxExtensions

Implement my custom operators.
Swift
2
star
21

waiwai-swift-demangler

waiwai-swift-demangler
Swift
1
star
22

OpenInBrowser

ランチャー騒ぎでリジェクトされたアプリのお墓です。線香でも上げてやって下さい(´・ω・`)
Swift
1
star
23

Builder

Introduce if/switch/for expression in swift.
Swift
1
star