Creating Forms with Eureka iOS Library

Vik Denic
vik’s code journal
2 min readDec 12, 2015

From afar, a simple form in iOS appears quite simple. You just manage some rows and maybe sections. Some formatting here or there. Quick and simple, right?

Not so much. Even if you’re building a simple form, you need to deal with the complexities that come with UITableView and its accompanying delegate and datasource. It’s not all that bad, but it can be better.

Enter Eureka: a Swift open source project designed to easily build dynamic table-view forms in Swift.

Eureka takes advantage of Swift language capabilities such as generics, functional and protocol oriented programming, operators, protocol extensions and much more to make form completion how it should be: simple.

In a current project of mine, the user can navigate to Settings where they have some basic options available to them:

A simple form of Sections with LabelRows

Typically, this would require plenty of tedious code dealing with the UITableView data-source and delegate methods. But with Eureka, my code for this was relatively simple and straightforward:

The custom operators make for readable and organized portions of code. And the learning curve should be fairly quick.

With my viewcontroller subclassing FormViewController, I make use of Eureka’s Section and Row objects to create the form at a high level.

Here I only needed the basic LabelRow, but Eureka is also full of much more dynamic rows. To check these out, clone their repo and run the example project.

I can already tell this is a library I will be using quite often, as it has already saved me time and made my code more readable in the process.

--

--