Automating keyboard layouts

Normally, developing a keyboard interface starts with putting a UITextField, a UITextField, or another UIResponder into your application’s view hierarchy…

And then this component becomes a statement: “From here forth, I declare this view to be a keyboard input view”. Except… Well… it isn’t, or at least doesn’t act like it. Unless you manage the layout of your content by implementing your keyboard notifications, the app’s main view will not respond or adapt to the keyboard update, and all sort of messed up situations can arise from this, like the keyboard overlaying your UITextField, UIScrollViews not being able to scroll or UITableViews not being able to display their last rows of content.

Continue reading “Automating keyboard layouts”

Subscripting String Shortcuts

The use of subscripts in Swift has added a few nice features to its predecessor in Obj-C, not only for reading, but also for writing your own implementations.

If you are not familiar with subscripts, they define the logic that allows you to write shortcut accessors and setters for objects that can be understood as a collection, and are most commonly used in Arrays and Dictionaries:

var array = ["Hello", " ", "World", "!"]
array[2] //subscript returns "World"
array[2] = "Everybody" //The word "World" is now replaced with "Everybody" using a subscript

Continue reading “Subscripting String Shortcuts”