Latest 0.2.0
License MIT
Platforms ios 9.0

CI Status
Carthage compatible

Smart error alerts and full-fledged empty state views on your ViewControllers just a protocol inheritance away.

To add ErrorKing to your ViewController, extend it with the ErrorProne protocol:

extension MyViewController: ErrorProne {}

That’s it! You can now call your ViewController’s new property: errorKing, and see it’s effects.

self.errorKing.setError(title: "Damn!", description: "Sorry for that.", emptyStateText: "Something happened :(")

Now, the next time your ViewController is visible (if the user triggered a load but pushed another screen, for example), ErrorKing will display:


Additional Customization

To dictate what happens when the empty state’s reload button is touched, override ErrorProne‘s errorKingEmptyStateReloadButtonTouched:

extension MyViewController: ErrorProne {
    func errorKingEmptyStateReloadButtonTouched() {
        //load my stuff again
        errorKing.errorKingEmptyStateReloadButtonTouched() //This will remove the empty state from the screen.

You can also program what happens before the empty state is displayed:

func actionBeforeDisplayingErrorKingEmptyState() {
    //do something before displaying the empty state screen, like disabling your tableView's scrolling
    errorKing.actionBeforeDisplayingErrorKingEmptyState() //Sets up and displays the empty state screen.

…and change the empty state’s frame if needed:

self.errorKing?.setEmptyStateFrame(rect: aFrame)

Providing your own EmptyState screen

To add your own Empty State view, simply make a .swift/.xib that has ErrorKingEmptyStateView as it’s class or superclass and link the corresponding outlets, if you used a .xib, or set errorLabel and init a button that triggers tryAgain:, if you use view code. After that, call:

self.errorKing.setEmptyStateView(toView: myCustomEmptyState)

You can see it in action on the Example project.




github "rockbruno/ErrorKing" "master"


pod "ErrorKing"


rockbruno, [email protected]


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

Latest podspec

    "name": "ErrorKing",
    "version": "0.2.0",
    "summary": "Swift Lib to make displaying errors and emptyState screens a very easy task",
    "description": "TODO: Add long description of the pod here.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "rockbruno": "[email protected]"
    "source": {
        "git": "",
        "branch": "master",
        "tag": "0.2.0"
    "platforms": {
        "ios": "9.0"
    "source_files": "Sources/Classes/**/*",
    "resource_bundles": {
        "ErrorKing": [
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This