Hashing

I find it hard to believe that any developer can deny the importance and usefulness that a right use of hashes can offer their applications.

From security and data management to object comparisons, hashes are used extensively throughout the framework and should, in the right circumstances, be used by you as a developer when the time merits them. But, what exactly is a hash? Simply speaking it’s a form of encryption that maps data of arbitrary length to a data object of a fixed size (number, string, etc),  but if you want to get all technical you can read this article on Wikipedia, wherein it explains hashes and it’s use through hash functions:

Continue reading “Hashing”

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”

Extending UIColor

After writing my previous article: “Subscripting Shortcuts” I tried to come up with a good usage of string subscripts in iOS, and decided a good example was to boost the power of UIColor by adding a couple of initializers that catered for two more widespread colour notations that are more common in the design and web industries: 255-RGB and HEX.

In this tutorial we will make use of our favourite tool, categories, to extend the base power of the framework’s UIColor class and allow for new ways of creating colours. Bear in mind that these initializers are geared towards speeding up development processes in sacrifice of  performance, specially when it comes to communications between developers and the design team. They will inherently produce a very small performance overhead on any app that adopts them (specially the hex conversion, as we will be doing string parsing and string parsing is ALWAYS expensive). Having said that, unless we iterate though a huge amount of colour objects, we can safely consider the knock-on effect as dismissible.

Continue reading “Extending UIColor”

Smarter Numbers. Annex 1: Custom operators.

On my earlier post, “Smarter Numbers”, we talked about using operator overrides in swift to extend the functionality of framework classes.

There’s a bit more to it than what was discussed in the article, but we’ve decided to keep it as a separate post due it’s less “orthodox” usage: Swift also allows you to, in what could be considered as a controversial feature, create custom operators. This means that not only can you change the behaviour of the language. you can also change the language itself*.

Continue reading “Smarter Numbers. Annex 1: Custom operators.”

Smarter Numbers

When it comes to iOS app Development, I find one of the most commonly used framework class is NSNumber.

Which is ironic, because it’s a pretty dumb class. Really… there’s not much you can do with it except store numbers and check for equality. Albeit it being all over the place, it’s a pretty useless wrapper object. Whenever we need to edit the wrapped value we need to go through overly complicated statements like this:


number1 = NSNumber(float: number1.floatValue + number2.floatValue)

Fortunately for us, Swift is AWESOME.

Continue reading “Smarter Numbers”

Ready… Set… Xcode! Annex 2: challenge … ACCEPTED!

On my first blog post, “Ready… Set… Xcode!“, we ended off with a challenge: to build a utility tool that could automate new project deployments.

There’s a couple of solutions you could use to solve this problem. You could write a Unix script, an apple script, or (if you want to be overkill) a whole dedicated Xcode project. I did, though, suggest that you use this little guy →

Automator

Why?
Because Automator is simple, fast and allows you to provide easy to use UI feedback. As a tool it is also completely undervalued… And the little A.I. bot is adorable… Yes, I just said it.

Continue reading “Ready… Set… Xcode! Annex 2: challenge … ACCEPTED!”

Ready… Set… Xcode! Annex 1: General project architecture… Explained.

A more detailed explanation for the architecture diagram referred to in “Ready… Set… Xcode!”.

On my first blog post, “Ready… Set… Xcode!“, we spoke about a general project architecture that is common to standard iOS Apps (note that architecture for games can be considerably more complex).

Here is a copy of the diagram to refresh our memory:Untitled drawing As you can see, in the middle we have the one design pattern to rule them all: the MVC pattern, roughly taking around 70% of the entire application’s architecture. A brief explanation of the components in this diagram follows: BASE (what you get for free):

Continue reading “Ready… Set… Xcode! Annex 1: General project architecture… Explained.”

Ready… Set… Xcode!

As is common in every app development cycle, there comes a time when we must start setting up a project.

This normally involves mundane and boilerplate tasks such as setting up folder structures, linking up the project to the right third party libraries (if needed) and adding reusable extensions/categories/classes from earlier projects that we have grown an affection towards or have become fully dependant on. Depending on your ability, how meticulous and orderly you are with these kind of things, your team size, the project size and how important an understanding of the overall architecture is for you as developer (very important), this can take you anywhere from a couple of hours to (hopefully not more than) a day. Depending on how many applications you work on during the course of your career, these times add up to considerable numbers (make the maths in your head and cringe).

Continue reading “Ready… Set… Xcode!”