UIViewController Extension to create a global UIActivityIndicatorView

You shouldn’t repeat code, so don’t!

One of the many things iOS developers need to do over and over again is to display a UIActivityIndicatorView in a UIViewController. However, most of the time this seems to be accomplished by adding a UIActivityIndicatorView to each controller, which does not adhere to the DRY principle.

Thankfully, using Swift extensions, it is very easy to create a global activity indicator.

Read more

Convert Dictionary Keys from snake_case to camelCase in Swift 2

RESTful APIs often return json dictionaries with keys formatted using snake_case, particularly for back-ends build in Ruby or Python frameworks. However, Swift typically uses the camelCase convention for object properties, which can make converting json responses to Swift objects a little too verbose.

Never fear, with a few quick extensions you can make this conversion a breeze.

Read more

Insert Horizontal Separators Between UITabBarItems in Swift 2.0

Here’s a quick overview of how to insert horizontal separators between each UITabBarItem in a UITabBarController in Swift 2.0 just like this:

swift uitabbaritem horizontal separator

All the necessary code goes in the viewDidLoad method of your UITabBarController.

Read more

How to Draw a Speech Bubble in Swift 2.0

Here’s a quick example of how to create a custom UIView to display a speech bubble in Swift 2.0 just like this:

swift uiview speech bubble

Step 1: Subclass UIView

Firstly, you need to subclass UIView as follows.

If you intended to use storyboard, ensure that you replace the fatalError line with super.init(coder: aDecoder)

class SpeechBubble: UIView {

    var color:UIColor = UIColor.grayColor()

    override init(frame: CGRect) {
        super.init(frame: frame)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

Step 2: Override drawRect(rect: CGRect)

Read more

Hello

Hello there,

Welcome to my personal blog where I’ll sporadically and infrequently post about Hilenium and neat Swift and Symfony2 tools and resources that I come across.

A word about Hilenium

Julian, my business partner, and I decided to build Hilenium to help agencies and marketers work better together.

Between us we have decades of complementary experience, with Julian having built a successful web agency and I having worked as a CMO and senior marketer in a range of companies and successful startups.

Together, we will make it easier for agencies and marketers to pitch ideas, collaborate on projects and deliver exceptional marketing outcomes.

All the best!

MC

Read more