Nikolay Blokhin Facebook Nikolay Blokhin Photos Nikolay Blokhin Linkedin Nikolay Blokhin Twitter

Hi, I'm Nikolay Blokhin

Swift articles

My collection of the best articles about Swift :)
All the articles I'm selecting manually and publish updates every day.

2017 April

2017.04.26

In this episode, we continue the implementation of the NavigationControllerRouter by creating an abstract factory protocol, a factory test stub and a new type representing a Question.

As discussed in the previous episode, we decided to create an abstract factory to decouple the Routing module from the UI module, maintaining our architecture clean and flexible. To achieve that we create a factory protocol, agnostic of concrete implementations.

to read it →
2017.04.26

There are two types or programmers: Those who handle errors properly, and those you don’t want to work with.

It’s happening over and over again. Something has stopped working and I need to fix it. After tens of minutes of debugging and diving deeper into the code base, I finally find it. Someone (including several-years-ago myself), ignored an error and left it unhandled.

to read it →
2017.04.26

Because I was having a heck of a headache in trying to find out why Swift imports don’t work in my app extension targets.

After a few times of starting from scratch...

to read it →
2017.04.26

Storing API Keys and Other Constants in .xcconfig files

After your app is on the App Store, you’ll have at least two states of your app to maintain: the app as it is on the App Store, and the app that you actively add features to in development.

If you have a server running in the backend, you’ll definitely have a server for production and a server for active development. On the iOS development side, we need some way of organizing our code base to prevent crashing the production version of the app.

to read it →
2017.04.26

On a recent episode of Fatal Error, the hosts talked about why they’d never use Core Data in a new project. I’m one of those people as well. I’d definitely recommend listening to the episode, but I also thought I’d jot down my reasons for never using Core Data if I have a choice in the matter.

If I had to summarize my problems with Core Data in one word, it’d be this

to read it →
2017.04.25

How to migrate iOS API Reference from Doxygen to Jazzy … and start supporting Swift. At Firebase, we moved our iOS API reference docs from Doxygen to Jazzy. Here are the issues we faced and the full migration guide.

Add comments for all interfaces, protocols, properties, methods, enums, structs, and typedefs.

If you don’t have documentation for one of these elements, Jazzy will still include it in the output, marked as “undocumented”. You can use the --skip-documentation parameter with jazzy script to see which declarations in your public headers are missing documentation.

to read it →
2017.04.25

At Firebase, we were using Doxygen to generate iOS API reference docs. While it did the job for ObjectiveC, it wasn’t supporting Swift. We started using Jazzy for the look and feel of Apple’s official reference documentation. The documentation which iOS developers are used to.

jazzy is a command-line utility that generates documentation for Swift or Objective-C. It is composed of two parts:

to read it →
2017.04.25

So Swift Protocol-Oriented Programming (POP): a new paradigm overthrowing Object-Oriented Programming (OOP), or yet another hype? There are articles over the internet saying farewell to OOP and gladly welcoming POP — as an example take blog entry from NIkant Vohra. This hype can be harmful to programming beginners — they might come to conclusion that they do not need the OO paradigm, and they will not learn about it nor from it. Why would this be a mistake? Read on.

to read it →
2017.04.25

The psychology of software developers fascinates me.

Before I get on with it, a quick proviso. At FullStory, Google, Innuvo, and other companies, I’ve done lots of hands-on coding as well as managing teams of other developers, so to the extent anything I say in this or future posts comes across as a criticism, it applies to me at least as much as any other developer. And, of course, it’s always dangerous to generalize about “how people are” so if you find yourself annoyed with anything I write here, please feel free to just assume that I didn’t mean for it to apply to you.

to read it →
2017.04.25

I give you nested computed properties in functions:

import Foundation func f() { var s: String { return "\(Date())" } print(s) sleep(2) print(s) } f()

Yeah. Today’s is courtesy of Mike Ash.

to read it →
2017.04.25

Earlier this month we launched Apollo Client 1.0, and it was super exciting: There were some great comments on the Hacker News thread, a ton of new downloads, and many new developers joined the Apollo community.

Our core idea — that managing data in your frontend should be simple — has really resonated with people. That’s what Apollo is all about. We’re working hard with the GraphQL community to make data loading and management straightforward, so you can focus on building a great app.

to read it →
2017.04.25

Here are the two use cases motivating my Last Item in a Non-empty Array post. You can see the entire gist here. The first method uses the guarantee of a non-empty array and notes it in an associated traditional comment. I have no problem with this. I should note that this second method is defined right after...

to read it →
2017.04.25

With Objective-C we were able to declare methods of a protocol as optional.

The objective-c compatibility way.

It is not necessary to implement that method if we were not going to use it. Swift protocols on their side do not allow optional methods. But if you are making an app for macOS, iOS, tvOS or watchOS you can add the @objc keyword at the beginning of the implementation of your protocol and add @objc follow by optional keyword before each methods you want to be optional.

to read it →
2017.04.25

A couple of months ago, I was thinking I hadn’t been giving iOS that much attention. For the past years, I’ve built some apps and done my share of experiments, but haven’t actually invested as much as I would have liked to. You know, in the midst of deadlines it’s not easy to get past the “it works” phase and move on to the next. Well, this time it was an experimental app and I had nothing pushing me, so I set a very slow pace. It was a fun experience which I’m eager to share.

to read it →
2017.04.25

Thoughts? Preferences? For the context behind this, see this post, and the screenshots in particular. Option 1:

extension Array { /// Return last element for array that is guaranteed /// to have at least one element public var lastOrDie: Element { assert(!self.isEmpty, "Array is guaranteed nonempty") let finalIndex = self.index(before: self.endIndex) return self[finalIndex] } }
to read it →
2017.04.25

There are a lot of people asking me now and then about whether to start learning Swift or Objective-C to get into the mobile dev scene. Also, a lot of people that develop for other platforms are often curious about Swift and Objective-C. This is for both of you, to get to know a bit more about the subject of the mobile platform languages available for iOS.

So Swift or Objective-C?

to read it →
2017.04.25

Every function; every class; every struct and enum and protocol is an API.

As developers, we move into and out of the role of “API Designer” constantly.

Have you ever thought about that? You are an API designer! You create Application Programming Interfaces all the time.

I believe that everything we create has design built in, whether we’ve thought much about it or not.

to read it →
2017.04.25

Mobile users have come to expect the UI consistency and performance that can only come from native apps. Building a feature-rich iOS app with an elegant user interface can be challenging, though. Fortunately, by using an app template, you can save substantial amounts of time and effort.

CodeCanyon has a huge collection of Swift language iOS app templates. If you don't know what an app template is, it is basically a pre-built application with a lot of the core functionality already implemented for you. You can then easily customise and add to the template's code to create the final app you want. 

to read it →
2017.04.25

In this article I will be discussing Structs in Swift.

Classes and structures are general-purpose, flexible constructs that become the building blocks of your program’s code. You define properties and methods to add functionality to your classes and structures by using exactly the same syntax as for constants, variables, and functions...

to read it →
2017.04.25

Good UI animations can greatly improve user experience of a mobile app if it is done precisely. It is usually one of the factors that differentiate a great app from a mediocre one. Designing a meaningful and functional animation is hard. The same goes for implementation. In particular, if the animation or view transition is extremely complex, it is a hard task for iOS developers to implement it in the app. Assuming you are not an indie developer, you are probably working in a team of developers and UI/UX designers. How many times have you come across this situation? Your...

to read it →
2017.04.25
extension UIColor { convenience init(rgb: Int, alpha: CGFloat) { let r = CGFloat((rgb & 0xFF0000) >> 16)/255 let g = CGFloat((rgb & 0xFF00) >> 8)/255 let b = CGFloat(rgb & 0xFF)/255 self.init(red: r, green: g, blue: b, alpha: alpha) }

convenience init(red: Int, green: Int, blue: Int) { self.init(red: CGFloat(red), green: CGFloat(green), blue: CGFloat(blue), alpha: 1.0) }
to read it →
2017.04.25

When I first started iOS development, I was always curious about best practises used by giant companies. How does their project structure look like? What architecture are they using? Which third party libraries are the most popular? This was my urge to build upon other people’s experience and don’t waste time on problems that are already solved.

It has been 4 years since. I worked with many clients and had many smart people on my team to discuss about these coding practises. So in this post, I want to talk about the not-very-obvious practises that I am using right now for iOS development.

to read it →
2017.04.25 1. Create file slc.sh then copy below code in to it.
TAGS="TODO:|FIXME:" ERRORTAG="DANGER:|ERROR:" find "${SRCROOT}" \( -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$|($ERRORTAG).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/" | perl -p -e "s/($ERRORTAG)/ error: \$1/" #find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$|($ERRORTAG).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/" | perl -p -e "s/($ERRORTAG)/ error: \$1/"

2. In Xcode...

to read it →
2017.04.25

Yesterday a new Swift source compatibility test suite was made available by those fine folks from the fruit. The suite is a community project that can be found here.

This interesting list of projects in the suite are periodically tested against development versions of Swift to hopefully find and fix incompatibility issues.

to read it →
2017.04.25

I’m often asked how to migrate an app from using storyboards or per-view controller code-based flow to an app using coordinators. When done right, this refactoring can be done piecemeal. You will continuously be able to deploy your app, even if the refactoring isn’t complete.

To acheive this, the best thing to do is start from the root, which for coordinators is called the “app coordinator”. The app delegate holds on to the app coordinator, which is the coordinator that sets up all the view controllers for your app’s launch.

to read it →
2017.04.24

The syntax for Swift Optionals can be pretty intimidating at first, so I’ll break down what the different syntaxes mean. To start, let’s say that we want to get the first thing out of an array

Notice that the return from this first property has a type of String?, that’s because it returns an optional String. Any time there is a ? at the end of a type, then you know you’re dealing with an optional.

to read it →
2017.04.24

A keen developer writes a lot of unit tests to cover the code to use in production. Unfortunately, a component can sometimes be difficult to test because of its dependencies, and you would be tempted to give up. Hang on, Test Doubles are what you need to make a test easy to write.

to read it →
2017.04.24

Today I am happy to announce Forge, an open source library that makes it a bit easier to build neural networks with MPSCNN.

Why do you need Forge?

Apple’s MPSCNN framework is great for creating really fast deep learning networks on iOS devices. It uses the power of Metal to get the best possible performance out of your iPhone’s GPU.

to read it →
2017.04.24

There is a very famous line on Swift “Time to Shift to Swift — The Future of Enterprise Application Development” which clear the advantages of it. This is just to clear the concept of swift to those who are not technical. Like other, this is also one of the outstanding inventions. Here is an overview of all the features with the help of which we can understand the term completely. Swift app development is actually a compiled and multi-paradigm language. It runs on OS X, watch OS, tv OS development and iOS.

to read it →
2017.04.24

Hi, i’m the creator of the macOS Jirassic app, an app that will track your worked time mostly automatically https://github.com/ralcr/Jirassic Recently I had to implement syncing and backup for few reasons: iOS app is waiting to be developed; when working from the office and from home on two different computers logged time will be scattered and hard to manage; future plans of syncing with other services like Jira tempo. I never used it before but i chose to use CloudKit because users are already logged in and because it is not doing any magic of caching stuffs for me like Firebase. I also believe it will not die suddenly like Parse, although it is free, we are actually paying for it through the developer account and iPhones, like our macs pay for that spaceship Apple is building.

to read it →
2017.04.24

I like using composition and dependency injection, but when you need to inject each entity with multiple dependencies, it can get cumbersome fast.

As the project grows and you need to inject more dependencies into your objects, you will end up having to refactor your methods a lot of times, as we all know Xcode doesn’t help with that.

There is a more manageable way.

to read it →
2017.04.24

Swift is truly protocol-oriented language. Since introduced in WWDC 2014 and open sourced in December 2015, it become one of the popular language for developing iOS application. You can watch this WWDC video to know about protocol oriented programming with Swift. In the recent days, protocol-oriented approach is definitely dominated the object oriented approach at least for Swift. It means we have to gradually forget about writing classes and start writing protocols instead. In this detailed and step by step blog post, we will see how to drive development from behaviour a.k.a BDD using Swift protocols, extensions and enumerations.

to read it →
2017.04.24

Recently I submitted a pull request with the following code: preferredButtonAction: { self.submitLogin() }

My mentor suggested that I replace my code with the following, in order to avoid a strong reference cycle:

preferredButtonAction: { [weak self] in self?.submitLogin() }

But what is a strong reference cycle? Why does it matter? And if it’s so bad, then why is strong the default behaviour instead of weak?

to read it →
2017.04.23

You are probably curious about what happened to my 100 Days of Code posts? Or the project?

I decided to stop making reports because I learned what I needed to learn from taking part in the project. I learned that writing code every day of the week for a living means I satisfy...

to read it →
2017.04.23

Examples are just supposed to be examples, so I can’t fault them for just being examples. If I’m looking at an example of how to construct a Firebase query in Swift, I’m probably trying to learn simply how to write a Firebase query in Swift, not how to separate Firebase concerns from my view controller, or otherwise how to write really clean code that just happens to involve Firebase.

to read it →
2017.04.23

The first creational design pattern that I would like to discuss is the builder design pattern. This design pattern comes extremely handy when you want to create different variants of an object while avoiding constructor pollution. Useful when there could be several flavors of an object or when there are a lot of steps involved in creation of an object.

Let me give you an example of how constructor pollution or telescoping constructor anti-pattern...

to read it →
2017.04.23

In this tutorial series, I will try to explain design patterns by picking up the world’s favorite language (arguably) — Swift

Design Patterns are not solutions to problems. You cannot expect to plug it into your program and expect some magic to happen. They are merely guidelines on how to approach a particular problem.

to read it →
2017.04.23

In this episode, we finish test-driving the functions responsible for starting and scoring the game.

To keep the Flow type internal to the module, we decided to create a public Game class representing the game state in play. A Game instance needs to be strongly referenced throughout the gameplay so we can appropriately deal with memory management and be ready to easily add new features, such as saving the current game state or stopping/halting the Quiz midways.

to read it →
2017.04.23

A lot of code that we write relies on the current date in some way. Whether it’s cache invalidation, handling time sensitive data, or keeping track of durations, we usually simply perform comparisons against Date() — for example using Date().timeIntervalSince(otherDate).

However, writing tests against code that uses such date comparisons can sometimes be a bit tricky. If the intervals are small enough, you could simply add...

to read it →
2017.04.23

In part 2 I will be going over various issues that you’d encounter if you completed part 1.

Here’s somethings we will go over:

  • Deletion of an entry with slide to delete
  • Dismiss keyboard when pressing enter
  • Self-sizing cells to accommodate more text
  • Most recent entries should be at the top
  • Add date/time stamp to each entry
  • How to use custom RGB colors for UIKit elements
to read it →
2017.04.23

Functional Programming by Wikipidia:

“Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data”. In other words, functional programming promotes code with no side effects, no change of value in variables. It oposes to imperative programming, which emphasizes change of state”.

What this means?

  • No mutable data (no side effect).
  • No state (no implicit, hidden state).

Once assigned (value binding), a variable (a symbol) does not change its value.

All state is bad? No, hidden, implicit state is bad.

to read it →
2017.04.22

Starting a Project

  1. Download and install Xcode from the App Store.
  2. Open Xcode, and select ‘Create a new Xcode project’.
  3. Select Single View Application from the iOS >Application list.
  4. Click Next
  5. Configure your project...
to read it →
2017.04.22

This tutorial will help you answer your code challenge for following iOS interview steps. Check out my other series: 50 iOS Interview Questions And Answers Part 1 Part 2 and Part 3.

This answer is confirmed by two company. If you have more eligible and proactive solution, please send me details and lets add these content.

to read it →
2017.04.22

So the story goes a little something like this… I was working on building an iOS application using swift with a couple of people and we decided to use firebase as a database solution. As we were building the application we came across a scenario where it really just didn’t make sense for the app to run this code, rather it would make sense to have the server run it everyday at midnight.

Thankfully Firebase recently came out with the option to write cloud functions...

to read it →
2017.04.22

I was one day scrolling through my Twitter timeline and there it was under “incase you missed it”. I for once never thought I’d see anything of great importance that would have stopped me from clicking the “dismiss” option but there it was: Someone(Akapo Damilola Francis) who I know knew his shit, asking for people who were interested to apply for a brief mentorship program.

Yes, I clicked. Yes I got in and YES! It was a great decision.

to read it →
2017.04.22

A few days ago, I started experimenting with LLVM and Swift. I have read many articles about LLVM and came to know LLVM has APIs which can be used in Swift. But I couldn't find any article which explains setting Xcode project with LLVM. After a lot of trial and error, I finally did it. I thought of sharing the steps so that it will help others who are starting. This tutorial shows how you can setup a Xcode swift project to use LLVM C APIs. First of what is LLVM? Why you need to use it in a Swift Xcode project. Maybe this is the first question come to your mind. Right?

If you never heard of LLVM and coded in Swift. Then you are unknowingly using LLVM.

to read it →
2017.04.22

So 3 months ago I was tasked with getting a payment terminal to work with my previous company’s point of sales app, and finally got it finished recently. We had not been given any sort of indication on how to connect to the device, or even what type of Bluetooth the device used (be it plain BT or BLE). Plus serial programming as a whole was new to me.

to read it →
2017.04.22

In this article we will be using the basic foundations of Core Data and how to use it in a real world iOS example by creating a simple journal entry application that utilizes Core Data to save, retrieve and delete your entries.

What is Core Data? Core Data is a framework that you use to...

to read it →
2017.04.22

On that faithful day, i received a mail via GDG group i subscribed to when I was in school about an iOS mentorship program. On checking it, i saw the mentors name (Akapo Damilola Francis) and voila i got interested in it immediately. Well who wouldn’t want to work with Akapo Damilola Francis especially if you have seen him work or speak before. I really admire is attitude to work and the his perspective about things.

to read it →
2017.04.21

If I’d use storyboards, would be like this. Although, your approach is still very similar to just using nibs. I would still prefere to use Nibs, because you get even more advantages. By handling the initialization your self, when you init a viewController you know what it needs in order to work, by passing the models or viewModels through the init of that viewController, you will never forget to pass the data that it needs. Also, you can build the app with only components, so every nib is a reusable component that joining them together makes...

to read it →
2017.04.21

If you were to ask me, there’s no shortage of databases available for the web. MongoDB, Postgres, MySQL, RethinkDB. The list goes on.

What about mobile apps ? What options are there if you want to integrate a database for your mobile application ? Popular ones include SQLite, CoreData, and Realm.

to read it →
2017.04.21

If you're developing an iOS app that involves monetization features such as premium content, licenses or even real world transactions, it's important to know that it's very simple to hackers to manipulate what happens in your app. Class data and properties can be easily inspected, allowing them to bypass subscription features, develop cracked versions of your app and even compromise your company's systems depending on how much critical content you're exposing in your app.

to read it →
2017.04.21

Category in Objective-C, Extension in Swift are the same concept. They can help you to organise your class code. With category and extension, you don't have to create a inherited class.

to read it →
2017.04.21

MeowlWatch can be downloaded on the App Store with keywords “MeowlWatch” or “Northwestern Dining”.

Northwestern students on the weekly meal plan struggle to manage their meal balances. For every meal on campus, students worry about their remaining meal swipes and equivalency meals. Although there is a website for checking your meal balance, many students — especially iOS users — have found it inaccurate and inconvenient.

to read it →
2017.04.21

Please enjoy this lovely MacBook photo as deep fear sets when I realize I’ve almost exhausted my stock photos source 😨 Optimizers be Optimizin’

From day one, I’ve always been driven by the end result of the software I was coding and less so about the magic that was happening underneath. Seeing the ubiquitous “Hello World” appear in terminal was astonishing to me. The further you go

to read it →
2017.04.21

Learn how to implement the depth-first search algorithm in Swift, in this step by step tutorial with downloadable sample code.

to read it →
2017.04.21

Here I’m exploring how to send mails programatically in Swift. Apple has provided MessageUI framework to implement mail functionality in your app. This framework has MFMailComposeViewController class which provides an interface to send/manage emails. We can use this controller to display a user interface within our app.

to read it →
2017.04.21

Many people ask us at NEXT Academy… Why do you guys teach iOS Development as opposed to Android development?

At NEXT Academy, our graduate outcomes are our top priority. Which is why, with limited resources we had to pick the best programming languages to learn to suit the current market.

Here are 7 good reasons why you should learn iOS Development...

to read it →
2017.04.21

So not everyone knows ~= operator — it’s an pattern matching operator to check whether the range on the left includes the value on right. The definition of this function goes like this.

It’s basically the same function as contains just wrapped in operator.

to read it →
2017.04.21

“When we add our protocols, we are saying that UIViewController are now going to take all of UITableViewController’s responsibilities.”

I like the phrase “going to take [the responsibilities]” — it puts a little more relationship back to the “delegate” concept. If I delegate something in real life, I expect the person I delegate to, to handle things… to take on appropriate responsibilities, as you put it.

to read it →
2017.04.21

Here is a simple tutorial to implement push notification in an iOS app.

‘This tutorial is based on the assumption that you are aware of the bundle identifier and already have a valid developer account.’

Firstly, open up Keychain...

to read it →
2017.04.21

There are a variety of design patterns that refer to wrapping existing classes inside of another class.

Especially recently, as we incorporate tests into our project, and continue to migrate our codebase from Objective-C to Swift, there are problems that arise with our original classes. For example, we can’t mock out certain view controllers, we can’t mock out our networking layer, and we can’t mock out any routing logic. So what should we do? Wrap ‘em!

to read it →
2017.04.20

This warning plagues me when I’m setting up a new project and moving all the files around and creating new folder structures.

Luckily I found this really helpful post. Read the comments — that’s where I found my solution.

to read it →
2017.04.20

Have you ever wondered why we need to declare delegate = self when we need to implement a protocol? I had a tough time initially understanding this concept. Today I’m am going to briefly explain why we need to declare self in delegates.

As some of you may know when we implement any protocol to our class or struct, delegates are involved. Let’s take UITableViewController as an example. If our class is a subclass of UITableViewController , then we do not need to declare our delegates because it already has all of it’s built in functions. In order to use UITableViewController ‘s functions, all we need to to do is override the function and implement it.

to read it →
2017.04.20

Given these two functions: p(x) -> Void executes side effects in its body. f(x) -> y produces a transformed value Prefer: if let x = x { p(x) } to x.map({ p(x) }) when executing a function for its side effects. return x.map({ f(x) }) when returning a transformed value based on an optional. You may think of map as inherently...

to read it →
2017.04.20

This is a short series on web design for beginners who already know a bit of Swift. Many of my classmates from the iOS cohort in Access Code are currently looking for jobs, and having a good web presence can help in attracting recruiters or impressing potential employers. It’s also a useful skill to have, in general, and not that hard to pick up the basics.

I hope that this series will serve as a good introduction for people who do not know HTML or CSS, and only a little Javascript, but who are still tech-savvy enough to have their own Github and a decent working familiarity with code.

to read it →
2017.04.20

Topic: Learn ios online : How to make tableview programmatically in swift3 | Free iOS Tutorials

What is UITableView? UITable​View is: Displays hierarchical lists of information and supports selection and editing of the information.

to read it →
2017.04.20

This post is based on a short talk I gave about using GCD with Swift 3.

We have been pretty bad with using the full capabilities of GCD - using only the main serial queue and the global background queue. Hopefully this will help you learn from our lesson.

to read it →
2017.04.20

This is 8th part of my series about creating Swift AST in Swift. In this part I will cover special kinds of function-like declarations.

In swift initializer is a common declaration, not required to be nested in class declaration...

to read it →
2017.04.20

I start this article with two quotes on protocol and generics. Both are core features of Swift. As we know, there are generics for class, struct and enum. What about protocol?

Suppose we’re working on a cache framework for our app. For different data type being cached, we often make them conform to an interface as following Cacable protocol.

to read it →
2017.04.20

I’m coming up on my 3 year anniversary of coding, and I have to say, I truly love what I do. Programming in Swift is a fascinating experience because I’m always learning something new; especially since the language is continuing to evolve at a rapid pace. There are so many different things that can now be accomplished with this language and I am eager to learn them all!

to read it →
2017.04.20

Extensions are great for extending classes but unfortunately, they cannot contain stored properties. Luckily, there is a work around using Associated Objects. Below, I have used associated objects to add a callback property to a UISegmented control extension making it easier to get the selected index.

to read it →
2017.04.19

Hamburger menus are always a hot debate even in 2017. They are often necessary but not the most effective in presenting overflowing menu items.

If you’re developing apps on both Android and iOS, you sometimes need to implement hamburger menus in iOS. Because hamburger menu is not a native iOS component/UX, it can be quite difficult to develop hamburger menu properly so that it doesn’t stick out like a sore thumb among other native iOS components in your app.

to read it →
2017.04.19

Recently I’ve been learning Objective C and iOS to work on a personal project. It’s been an interesting journey as Objective C is quite a change from Ruby and Javascript. However, more importantly the structure of iOS apps and how everything in the framework interacts was more of the mystery. I definitely wanted to figure it out as much as possible, rather than build a poorly structured product.For some reason today felt awesome, as I learned how to build out customized TableViewCells using a xib and inheriting from the UITableViewCell class. May not seem like much, and it probably isn’t… but it’s a strong step forward!

to read it →
2017.04.19

So I’ve noticed in our codebase that any time we receive a response from the server, it comes as a dictionary. This is cool and all, but I didn’t understand why… is it really necessary to send everything as a dictionary?

And then I stumbled upon this article, thanks to this Stack Overflow post, which outlines that evil people with malicious intent used to be able to extend the functionality of arrays, such that they could steal the contents oh so easily

to read it →
2017.04.19

Generics Are Beautiful. We Love Generics.

I’ve been listening to Joe Rogan’s Podcast recently hence this article will take place in the format of podcast for a different flavor. I hope you enjoy.

to read it →
2017.04.19

You may have heard the terms aggregation and composition when talking about object oriented programming. Aggregation and Composition are both design patterns that create a directional association between classes — meaning there is a parent/child relationship between the given types.

Lets say we are building a (simplified) human with a brain, heart, body, pants, and a shirt. We need to create separate classes for the brain, heart, body, pants, and shirt and associate them with the Human class. We can do this by giving the human class properties that are of each type.

to read it →
2017.04.19

In this episode, we create the Result type and refactor the Flow to accommodate scoring at the end of the Quiz game.

We spike some ideas on how to score the game and how to design the game models. We discuss about upsides and downsides of rigid types vs flexible types. We show different approaches to make your code more flexible and demonstrate that even with abstract types like protocols, we can create rigid designs that can impede us from maintaining a fast pace throughout the development cycle.

to read it →
2017.04.19

Swift Life Pro Tip: If you’re working with a Swiftized version of what was originally a Cocoa /Touch Foundation type, always check the header file just in case there’s more info that’s missing from the Swift version. To take an example from a conversation today, consider the following code. What happens if you pass nil rather than an...

to read it →
2017.04.19

Change the Top Bar Color

Hide Navigation Bar

Rounded corners and UIView shadows

Replace Back Button in a Navigation Bar

to read it →
2017.04.19

What do you do when you’ve got two (or more) optionals that you need to safely unwrap and work withjQuery21308182019424351445_1492664293024

Suppose that you’ve got two arrays, both of which are optional. What I want to do right now is walk through a couple of scenarios where I unwrap them at the same time and print them to the console with a single if-let statement.

to read it →
2017.04.19

Another minor release from Apple for Xcode taking it to 8.3.2 along with refresh Beta 3’s for macOS 10.12.5, iOS 10.3.2, watchOS 3.2.2, and tvOS 10.2.1.

As always, they are available from developer.apple.com

to read it →
2017.04.19

I’ve seen a lot of articles recently that argue aginst using storyboards when creating iOS apps. The most commonly mentioned arguments are that storyboards are not human readable, they are slow and they cause git conflicts. These are all valid concerns, but can be avoided. I want to tell you how we use storyboards on non-trivial projects, and how you can avoid these concerns and still get the nice things storyboards give you.

Why use storyboards?

to read it →
2017.04.19

Nowadays almost every app do a network request to authenticate a user, request an advertising data or to track how users use it. Network request is the way the app uses to update data and show new information without the need of the user update it at App Store or Google Play.

There are some libraries that help developers perform network requests on the iOS world. On this post, we are going to use Alamofire.

to read it →
2017.04.19

Great! You have a Vapor app running locally (or even on a remote machine). There’s just one problem. Before you can serve the latest changes from your remote machine, you’d have to go through a lot of steps which will most likely consist of the following...

to read it →
2017.04.19

0x00: Install Carthage on you mac:

brew install Carthage

0x01: Under your project root directory, vim Cartfile:

  • == 1.0 means using version 1.0
  • >= 1.0 means using version 1.0 or higher
  • ~> 1.0 means using version 1.0 but lower than version 2.0, i.e. 1.2
to read it →
2017.04.18

Are you developing an application which uses API responses? Do you need an efficiently way to test the UI? UI testing with a mock API server is the solution to your problems.

to read it →
2017.04.18

NSCache is an amazing Cocoa API which is often overlooked by the developers. NSHipster has an amazing article on it, so I’ll go straight to business.

In Swift 3, NSCache is a generic type. But it doesn’t work as a regular Dictionary. In Dictionary, any Hashable type (including value types, of course) can be used as keys. But NSCache has a strange KeyType : AnyObject constraint, which means that you cannot use value types as a key (which is understandable — NSCache comes from Cocoa).

to read it →
2017.04.18

LinkedIn recently open-sourced Bluepill which is a tool to run iOS tests in parallel. There is a Bluepill announcement blog post on LinkedIn Engineering blog. Bluepill wasn’t supporting Apple’s XCTest and XCUITests framework from scratch but with latest release v1.0.0 we can able to run XCTest and XCUITests in parallel using Bluepill.

to read it →
2017.04.18

Was chatting today about the freestanding old style partition function and the new one that’s part of SE-0120. One thing led to another and I was writing sleepsort in a playground. Several interesting things. To Linuxize, so I could run this in the IBM sandbox, I had to import Dispatch, use CLOCKS_PER_SEC, and use rand() (and no, I...

to read it →
2017.04.18

Are you developing an application which uses API responses? Do you need an efficiently way to test the UI? UI testing with a mock API server is the solution to your problems.

to read it →
2017.04.18

In this episode, we improve the Router and Flow components of the Engine framework by replacing the previously hardcoded String type for Question and Answer.

As shown in the first episode, we set a goal of being able to play the game with many types of questions and answers, such as text, image, audio and video. To achieve this level of flexibility, we decided to abstract the Question and Answer types by using Swift's generics.

to read it →
2017.04.18

Standard software development practice is to use different environments (testing, development, production, etc ) for the different versions of the software. iOS application development in this case is no different. Each software in particular environment uses different database, different url endpoints and even different resources. To cope with it building multiple targets helps you out.

Changing the codes in a particular target for an environment is vexing.

The whole process for this may be quite intimidating for you, but once you get it done by the end of this article, you’ll be heavenly satisfied :P. Just be sure you do not miss any of the steps.

to read it →
2017.04.18

We love Open-source software, without it we wouldn’t be here today, there isn’t a single area of our codebase that isn’t touched by it. It’s because it’s given us so much benefit, that we feel the need to give back.

We’re happy to announce the launch of three new open source packages, they’re all pretty small, much like we are, but they’re things we rely heavily on and find great utility in.

to read it →
2017.04.18

The last couple of years is witnessing the emergence of Swift, an iOS App programming language, as the most sought after for iOS App development. So much so, that developers and businesses are embracing it with open hands. But, what is Swift? Why do Enterprises prefer their iOS App development in Swift? Let’s know more.

to read it →
2017.04.18

This is a super quick blog to go over the Swift keyword — nil. nil is described in the Apple docs as:

meaning “the absence of a valid object.”

Not the easiest thing to understand if you’re starting out, right?

to read it →
2017.04.18

In trying to get to know the new ReactiveCocoa 5 framework, I decided to take the Ray Wenderlich tutorial and rewrite it with swift and RAC 5.

If you haven’t read it, I would highly suggest diving in. Its a fun tutorial and it gives a better introduction to ReactiveCocoa than I ever could.

This was also an opportunity to rewrite the starter application architecture to follow the MVVM pattern and tackle some unit tests with an application heavily dependent on RAC 5. I also decided to use PureLayout to buil

to read it →
2017.04.18

Splitting and trimming are likely the two more common operation we perform on strings.

In Swift, you can split strings in two ways, depending on the fact that you prefer a pure-Swift solution or if you decide to import Foundation.

to read it →
2017.04.18

I’ve been coding for iOS since 2009 and have been involved in the development of countless apps. These are some of my key learnings for efficient, maintainable and fun app development.

to read it →
2017.04.18

TagListView is simple and highly customizable iOS tag list view, in Swift. Supports Storyboard, Auto Layout, and @IBDesignable.

The most convinient way is to use Storyboard. Drag a view to Storyboard and set Class to TagListView (if you use CocoaPods, also set Module to TagListView). Then you can play with the attributes in the right pane, and see the preview in real time...

to read it →
2017.04.18

UIFontComplete make working with UIFont faster and less error-prone

This library is simply one extension to UIFont and one Font enum with a case for each standard installed font on iOS. No more muddling around searching for names of UIFont types and no more surprises at runtime if a font name was mistyped.

to read it →
2017.04.18

Why Realm? Let’s start with a little bit of introduction. The Realm Mobile Database is a cross-platform mobile database solution designed for mobile applications and it has a lot of advantages, for example, it is fast, easy to set up, and requires less boilerplate code. Moreover, the Realm Object Server has been released last year and perhaps I will try the macOS version in the future.

to read it →
2017.04.17

After elaborating on both sides of Core Data and SQLite in my previous post, I am going to start with letting you know how to get started with the Core Data library in Swift.

I’m making a simple contact list application to store all your contacts in one place. I have started with a new project with a Single View Controller and made a new UINavigationController with root view controller and dragged another View Controller into the app.

to read it →
2017.04.17

A simple Swift library that allows you to set and animate multiple placeholders on UITextField

Placeholder is a powerful concept with a long history — it’s easily recognizable by users, has a strict, reasonable meaning and gives the developer an easy way to hint their users.

to read it →
2017.04.17

Suppose you have something like the series of nested loops shown below, and you need a way to break out of these loop when a certain condition arises:

var array = [1,2,3,-1,5] var a = 5 outer: for j in 0...3{ while a>0 { inner: for i in 0..< array.count { if array[i] < 0 { //Exit prematurely! //jQuery21309484625477171937_1492455639068? } } a = a-1 } } a //0
to read it →
2017.04.17

Today I’ll be explaining the difference between let and var, two fundamental keywords in the Swift programming language. If you're just getting started with Swift this is a great place to start learning as you'll be using these two a lot!

Both let and var are used when defining variables. You can think of variables as bags of information which can hold a number, true or false, even some text, like "Hello, World!"

to read it →
2017.04.17

Updating your server-side Swift project to use Swift 3.1 introduces a big change to the way the Swift package manager works you may not be aware of - updating your dependencies will by default generate generate this Package.pins file. So what is this thing?

TL;DR: Package.pins is basically the same thing as Podfile.lock when using cocoapods.

to read it →
2017.04.17

Last week, I posted a tutorial to introduce how to change your app’s icon programmatically in iOS 10.3. Some readers left their questions: why do we need to change the icon dynamically? What are the use cases for this new feature? Other readers gave scenarios like showing match result for sport apps. But I think it’s not easy because the alternative icons are predefined. But there are still some cases in which we can leverage this new feature. They are only from my experience or my assumption. Please think twice if you want to make it in your product.

to read it →
2017.04.17

In a recent project, we used a lot of tableviews. Most UI’s like registration page, dashboard, etc were tableviews. The sections and rows of the tableview were basically represented as enums similar to this post.

However, one single screen required a dynamic tableview where the sections could be added and removed and the cells shown and hidden. It is difficult to achieve this behavior using enums and using a library for one single screen was not attractive. So we resorted to a different approach.

First we declared a protocol for every section of the tableview...

to read it →
2017.04.17

I love how easy Apple made it to add this feature to a table, it was one of those nice surprises that did not require a ton of code just to add a useful swipe gesture to a table.

to read it →
2017.04.16

SOLID is a mnemonic acronym named by Robert C. Martin used in Software Programming, It represents 5 principles of Object Oriented Programming.

  • Single Responsibility Principle
  • Open Closed
  • Liskov’s Subsititution
  • Interface Segregation
  • Dependency Inversion

These principle solve bad architecture problems like...

to read it →
2017.04.16

One thing about trends is that we try really hard to follow them no matter what it takes. Sometimes they don’t bring that much value (or even worse), but it doesn’t matter… We’ve already hopped on the trend-train!🚂

I see a lot of messing around Swift being considered as a multiparadigm language, or even functional language (not pure, but still). There are good resources proving it’s possible. Of course there are people on the other side, proving that Swift...

to read it →
2017.04.16

I’m sure you’ve done it hundreds of times, whether it be sliding a message or sliding an email.

In iOS a lot of UITableViews have something that looks like this...

to read it →
2017.04.16

Experimental project CodeGen - which creates code to multiple languages.. Even-though I have heard from people that once you learn one language it will be easy to learn new ones.. I quiet didn’t get the idea.. But later when Objective-C was superseded by Swift and almost at the same time I decided to not to stick on to just iOS and moved to web. I understood one thing…

to read it →
2017.04.16

In iOS 10, API to implement and run Convolutional Neural Network (CNN) on iOS devices have been added to the MetalPerformanceShaders (MPS) framework. We can now take advantage of GPU on iOS devices to run fast CNN computation. In other word, we can use outcome of cutting edge deep learning technologies on your device even while offline.

to read it →
2017.04.15

Since the beginning of 2017, I’ve had time to make a lot of OSS contributions — more than usual, including the creation of a couple new libraries. I’d like to take a moment and share them here.

to read it →
2017.04.15

I came up with a purdy good solution to my Firebase/TableView problem that I had been working on. I decided to go with the solution involving the .observeSingleEvent Firebase function. It might not make complete sense to you as a reader, because it involves some things that are specific to the app I’m building, but hopefully you can gain something from it.

to read it →
2017.04.15

I’ve been working with a team on a fitness app. The app will allow you to start or join a team, allow you to create fitness challenges for your team, and then track your progress through those challenges. We’re using Firebase to store all our database information, and I’ve been the primary person coding our Firebase manager.

to read it →
2017.04.15

Enumerations are a way of defining new data types. In this article I will be talking about the basics of Enumerations, or enum for short.

Think of an enum like a dropdown list, it only consists what’s contained in the dropdown list and you can only choose from that specific list.

Enums are also great for developers as it lowers our chances of errors or typos due to providing us autocomplete.

to read it →
2017.04.15

This week, I’d like to take you on a bit of a “behind the scenes” of Marathon (a command line tool that enables you to easily run & handle Swift scripts), and provide a step-by-step tutorial on the setup I used to build it it using the Swift Package Manager.

I personally really like the Swift Package Manager (which I will from now on refer to as ‘SPM’ to save me some typing 😅) and how easy it is to use once you get up and running. But it does have somewhat of a learning curve. So hopefully this post will make it easier for anyone looking to build their own tooling using Swift.

to read it →
2017.04.13

A lot of beginners have trouble with closures starting out so I thought I’d try to show it my way to hopefully help anyone out.

First, I’d like for you if you don’t already to grasp the foundation of functions in Swift. You can check out my post here on it, then come back here once you have functions locked down.

Let’s get into talking about closures.

to read it →
2017.04.13

When looking for options to deploy your Kitura Swift app to Bluemix, you may run across IBM Cloud Application Tools. IBM Cloud Application Tools provides a Mac app that is supposed to help you deploy your app to the Bluemix server. Unfortunately, I did not have a positive experience with IBM Cloud Tools as it kept freezing and was unable to upload my app to the server.

After getting dissapointed with IBM Cloud Application Tools I turned to command line tools. IBM has provided a starter project on Github where they discuss the process of deployment using terminal. Unfortunately, they missed a lot of steps and it is not clear how to do a successful deployment. Hopefully, this post will list all the required steps to perform a deployment to IBM Bluemix.

to read it →
2017.04.13

As a follow up to my article Introduction to iOS Concurrency, today I’d like to share my thoughts on how to improve the level of concurrency in an iOS application.

Operations can render assistance in concurrency. Operation is an object-oriented method of job encapsulation, that is to be done asynchronously. Operations are supposed to be used in conjunction with an operation queue or independently.

to read it →
2017.04.13

If you don’t know what optionals are or are confused on the topic, check out my last post.

I’ve noticed a lot of beginners do this so I thought I’d write about it.

When working with optionals, Xcode usually suggests you to unwrap an optional by adding a !.

If you do this without knowing 100% that variable/constant has a value, your screwing yourself in the ass.

to read it →
2017.04.13

We have introduced Free Source Code on our website, Piece.

You can download the Source Code for Free and integrate the code in your application. Please checkout Free source one on Piece — https://www.piece.cool/products/free

1. Fibonacci sequence generator

2. Realtime Hex Bin Dec Converter

to read it →
2017.04.13

Whenever I see unrecognized selector sent to instance I think to myself, wow, this is the least helpful and most vague description I’ve ever seen. But alas, we must work with what we got. So, the two most common culprits of this all-too-often error message is...

to read it →
2017.04.12

There is a new version of the OpenWhisk provider plugin for The Serverless Framework. This release adds support for non-Node.js runtimes, including Python, Swift, Docker and Binaries.

The update also includes improved error messages for application errors, invoke local support for the Python runtime and showing Web Action URLs in serverless info.

to read it →
2017.04.12

The icon of Apple’s official Clock app is amazing because it gives us a running clock. Although we can’t get this with public API, a small step forward has been taken in iOS 10.3. We can change our app’s icon programmatically.

Obviously, we need to prepare different icons. There are some requirements. The first one is size. For example, if our app is only for iPhone, the sizes are 60pt@2x and 60pt@3x which means 120120 and 180180. And its names should follow the rules like icon1@2x.png and icon1@3x.png. The second one is where we put the alternate icons. Generally, we put our app icon in Assets.xcassets, but not for the alternative icons. We usually put it in a group specifically for alternative icons.

to read it →
2017.04.12

Reactive Programming in Swift is getting a lot of attention these days, specially with the launch of RxSwift Reactive Programming with Swift book. I decided to try out RxSwift using by implementing a small project.

The project comprises of two screens. A table view, which displays a list of tasks and a add new task screen. The add new task screen is displayed as a model on top of the tasks list screen. Let’s see how RxSwift can be used to create this app.

to read it →
2017.04.12

Mobile security has become a hot topic. For any app that communicates remotely, it is important to consider the security of user information that is sent across a network. In this post, you'll learn the current best practices for securing the communications of your iOS app in Swift.

When developing your app, consider limiting network requests to ones that are essential. For those requests, make sure that they are made over HTTPS and...

to read it →
2017.04.12

This is a story of adding a button in the app I’m currently working on. My previous post was about adding a picker control in the same app.

So, the app is very basic, but is full of custom visual effects that take the most time to implement.

My goal here is the Start button. Its color changes with the selected values of the pickers above...

to read it →
2017.04.12

Today I’m writing an article about a common issue in iOS: autolayout with scroll view and handle keyboard event. This is a very simple problem but also very itchy for many developers. Hence, I’ll introduce my solution in this post.

The scenario: I have a view with some TextFields. Some textfields are at the bottom of the screen, so when I want to text something, the keyboard will show and cover the textfields -> can’t text anymore.

to read it →
2017.04.12

I like using composition and dependency injection, but when you need to inject each entity with multiple dependencies, it can get cumbersome fast.

As the project grows and you need to inject more dependencies into your objects, you will end up having to refactor your methods a lot of times, as we all know Xcode doesn’t help with that...

to read it →
2017.04.12

Optionals are basically a way to say “This may or may not have a value”.

A lot of newbies are unsure of what optionals are and how they work so I’ll hopefully try to explain this in an easy way to understand.

Best way to follow this post is through playground.

to read it →
2017.04.12

In the first part of the tutorial series, you have learned all you need to know about scenes, nodes, labels and points in SpriteKit by centering a label on the screen. In this part, you will move the label when you tap the screen using new SpriteKit concepts: Actions Sequences Gesture recognisers Adding a Gesture Recogniser to the Scene You are going to add a gesture recogniser to the scene so that the label moves whenever you tap anywhere on the screen. Add the following block of code to the didMove(to:) method in the GameScene.swift file right after you add...

to read it →
2017.04.10

Seth Willits was working on an interpolation protocol that would allow conforming constructs to interpolate from one value to another, regardless of their underlying types. It needed to work for CGFloat as well as Double, and be decomposable and useful for CGPoint and CGRect as well as any custom Swift Polygon struct. This created interesting challenges, as some of the most...

to read it →
2017.04.10

Of course, Swift protocol extensions and default parameter values are great features. And they are always safe, aren't they? Well, not really.

to read it →
2017.04.09

Suppose you are working on a Swift program that needs a data model to represent a contact, such as a person from the user’s address book or a FaceBook friend. You might start off by modeling this as a Contact...

to read it →
2017.04.07

Both nested types and generics are great features of Swift. Today, we will introduce nested generics which mixes them. It reminds me of Pen-Pineapple-Apple-Pen. :)

Let’s get started with a real world scenario.

to read it →
2017.04.07

Optionals are arguably one of the most important features of Swift, and key to what sets it apart from languages like Objective-C. By being forced to handle the case where something could be nil, we tend to write more predictable and less error prone code.

However, sometimes optionals can put you in somewhat of a tight spot, where you as the programmer know (or at least, you’re under the assumption) that a certain variable will always be non-nil when used, even if it’s of an optional type. Like when handling views in a view controller...

to read it →
2017.04.07

Swift 3.1 fixes a bug in the Swift Package Manager that prevented overriding the macOS deployment target.

When you run swift build on macOS, the package manager currently (as of Swift 3.0 and 3.1) hardcodes the deployment target to macOS 10.10. In Swift 3.0 it was impossible to override this due to a bug in the order arguments were evaluated.

to read it →
2017.04.07

Learn how to work with transforming operators in RxSwift, in the context of a real app, in this tutorial taken from our latest book, RxSwift: Reactive Programming With Swift!

to read it →
2017.04.06

Swift is moving on. To support different incompatible versions, we use #if swift(>= N) before Swift 3.1. For example the following simple code snippet, we print different information in different versions.

#if swift(>=3.1) print("Hello Swift 3.1!") #elseif swift(>=3.0) print("Hello Swift 3.0!") #endif
to read it →
2017.04.06

Push Notifications is a loud and powerful way for our apps to engage with our users. We engage with our users by letting them see values with their very owns eyes. Users see values. Users engage. We can engage our users by letting them know about something important. Perhaps their favorite sport team is about to compete. A flash sale on watermelons is on for 30 minutes. Or there is an important meet up in the desert later this weekend. These are some scenarios when our users may want to be notified. One way to implement push notifications for iOS...

to read it →
2017.04.06

Map and filter get a lot of attention, but I say reduce is the important one. Or if you’re interested in efficiency, how about this: you can build map and filter using reduce. If you’re going to learn about just one, pick reduce.

Map has the useful behavior of performing some operation on every item in the sequence and collecting the results.

to read it →
2017.04.06

In this blog post we’ll use a recurrent neural network (RNN) to teach the iPhone to play the drums. It will sound something like this:

The timing still needs a little work but it definitely sounds like someone playing the drums!

to read it →
2017.04.06

Form entry is never fun. Especially on a mobile device. In our app here at WeVat, we do require the user to enter some of their details manually, so we are striving to make that as painless for the user as possible!

One thing we have recently implemented is a simple progress view to subtly show the users how far through the process they are.

to read it →
2017.04.05

The Code This episode of “Style this” stars code from Brandon Trussell, who asked to “make this Swiftier”:

// Get the image name var imageName: String? = nil if let collection = songs { for song in collection { if (song.cover_url != "") { imageName = song.cover_url break; } } }

The Issues So what’s wrong...

to read it →
2017.04.05

Container Views allow us to add child view controllers via Storyboard. Child view controllers are convenient as they allow us to break up a complicated view and view controller in to separate, reusable views, each with their own view controller.

As child view controllers are used to separate related functionality, it is common to need references to our child view controllers in our main parent view controller. When child view controllers are added via Storyboard, we don’t automatically get these references. We need to explicitly get these references ourselves.

to read it →
2017.04.05

Learn how to leverage transforming operators in RxSwift, in this tutorial taken from our latest book, RxSwift: Reactive Programming With Swift!

to read it →
2017.04.05

Swift was introduced at WWDC 2014, and by this time, a 3rd version of this programming language is available. Since the time of release, it has gained immense popularity swiftly among iOS app developers. As more and more developers are adopting it, they have started to love this language.

Now, let’s delve into the topic. The title “It’s time to switch to Swift” is given for a reason. Being an iOS app developer, I like this programming language the most, and have started developing my codes with it. But to my shock, I found that despite being so popular and demanding, only a few developers have fully adopted this language.

to read it →
2017.04.05 There has been a ton of debate on the swift-evolution mailing lists about access control in Swift. A couple of days ago, the proposal SE-0159: Fix Private Access Levels was rejected. I want to share my thoughts on this, as well as thoughts on the larger story for access control in general. But first, let’s begin with a brief history of access control in Swift. to read it →
2017.04.05

Swift is commonly described as a “safe” language. Indeed, the About page of swift.org says:

Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.

to read it →
2017.04.04

How do I wait for an asynchronous closure? I am making an async network request and getting its results in a closure but somewhere I have to know that my request has been completed so I can get the values You can approach this several ways. The easiest is to post a notification or call a delegate...

to read it →
2017.04.03

I tend to use the phrases currying and partial application interchangeably. The Intertubes tell me, however,  that currying is limited to 1-arity stages. Arity refers to the number of a function’s arguments and should not be confused with Arrietty from the Borrowers. Swift is tuple friendly and given tuples, I mentallly stretch the “same thingity”...

to read it →
2017.04.03

TL;DR - Assigning a function to closure property creates a strong reference to the owner of the function potentially creating a retain cycle

Swift has first class functions, meaning that a function is treated like any other object, i.e. it's possible to...

to read it →
2017.04.03

A maintainable component. Reusable. Just a dream? Maybe not. SOLID principles, may be the way.

to read it →
2017.04.03

Closures in Swift are extremely useful, they are interchangeable with functions and that creates a lot of opportunities for useful use-cases. One thing we have to be careful when using them is to avoid retain cycles.

We have to do it so often that it begs the question: Can we improve the call-site API?

to read it →
2017.04.03

Dependency injection: splitting this english term for getting easy approach we get...

to read it →
2017.04.03

In my spare time I've been focusing on a number of validation bugs found within the Kryption app. I hope the following solutions provide some clarity for you, and at the very least you learn something.

Note: At the time of this post, the solutions were written in Swift 3.

to read it →
2017.04.02

While Swift does not yet feature a dedicated namespace keyword, it does support nesting types within others. Let’s take a look at how using such nested types can help us improve the structure of our code.

Many Swift developers are used to do namespacing through including structural levels in the actual name of a type — using names like PostTextFormatterOption (an Option for a Text Formatter used to format Posts). This is probably because this was pretty much the only way to do sort of a “poor man’s namespacing” in Objective-C & C, and like many other conventions it has carried over to Swift.

to read it →
2017.04.02

A quick note on Xcode project structure for multi project systems that are heavily reliant on Swift package dependencies

Over time, I’ve been developing a number of Swift packages that comprise a framework for my personal projects. The culmination of this ecosystem is a multi project solution with a number of servers, cli, macOS, and iOS applications. Each project shares a large number of package dependencies; because the system is so modular.

to read it →
2017.04.02

Everything was going just fine, it compiles and runs with issue. Then you run SwiftLint on the code and suddenly feel very sad. But in the long run, you know it will make you stronger….right?

If you want to feel the pain of being judged, install SwiftLint and see how well you. If you are using Brew...

to read it →
2017.04.02

Once upon a time, in a kingdom, not really far away, there was an evil queen. Her name was NSObject. To look nice, she was giving to her people lots of gifts. But the biggest treasure she was offering them was code reuse.

This code reuse was achieved through inheritance… from the queen! And thanks to this, the queen was keeping control over all her people for generations, and generations, and generations…

to read it →
2017.04.01

Following on from my previous article on Cross-Platform mobile development with Swift, I managed to get a sneak peak at Beta 2 of SCADE when they asked me to test the nightly builds before the public beta release.

To my delight, as well as dealing with issues reported during Beta 1 (improved installation process, some internal fixes and improvements), they also added a new category of project — a “Server Application Project”.

to read it →
2017.04.01

Some applications support both landscape and portrait mode but if you need to lock your application to the landscape or portrait mode, then you’re in the right place...

to read it →