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 June

2017.06.16

Recently I’ve got a task to allow Electron-based desktop app to add events to macOS Calendar. There are not too many options to do that. I’ve made up a way to provide a macOS native layer to that JavaScript app.

I’ve written a macOS command line tool in Swift to add events and reminders using EventKit framework. This was truly great experience. Last time I made command line tools about 10 years ago in pure C.

to read it →
2017.06.16

Applying mutableCopy() to an NSObject returns Any, not the version of the type you’re attempting to make mutable, for example, NSMutableArray, NSMutableParagraphStyle, NSMutableAttributedString or whatever. Nate asks: Is is acceptable to use as! with mutableCopy() or is there a better way to do this? // Approach 1: Forced unwrap let mutableStyle1 = style.mutableCopy() as! NSMutableParagraphStyle The forced as! cast used...

to read it →
2017.06.16

What is a structure? It is a type which group related data, which come in the form of properties (the values and constant) and methods(functions). It is a way to model what we want to represent in code, alongside Classes.

Highly relevant to note is that a structure is a value type. This means that if you create an instance of a type and you assign that instance to a different property, you are copying it, meaning that you will have 2 copies of that instance.

to read it →
2017.06.16

iOS 11 brings lots of new cool features like Machine Learning and Augmented Reality. So you might want to test those features or create awesome apps. But if you notice that some of them need a custom camera and accessing camera frames. iOS have lots of API’s for us to access device camera, capture image and process it. AVFoundation is the framework you should be looking at. Since this framework is huge and there is lots of ways to achieve the desired features I decided to write set of blog posts about the following.

to read it →
2017.06.16

Swift has become a very popular language for iOS Development simultaneously rising above all the criticism from objective-C comparisons.

No doubt it will be in a very strong position in very short time more.

In continuation Let’s discuss about its one more capability ‘extensions’ which was not found in obj-C.

Every developer must follow this and try to use extensions widely in there projects as it helps to build code more readable, scaleable and professionally well.

It allows you to add custom functionality to any pre existing class, structure or enumeration type.

to read it →
2017.06.16

iOS is an operating system which has successfully created fascination world-wide. This fascination and spell-binding impact must have looked day and night hard-work for iOS app developers. This hardwork is in the form of programming languages that are quite arduous for iOS app developers to learn. Objective-C defines that period when Apple had taken over the lost ground from Windows. Designed by Brad Cox and Tom Love influenced by C and Smalltalk, ensured its presence in the year 1983. Objective-C has catered to iOS app developers as well as users to create the magnificent impact till the advent of Swift in the year WWDC 2014 event. Swift although considered to be the fast yet safe and interactive OS X programming platform, which although belonged to the paradigm to object-oriented, functional, imperative and block structured. It was created under the influence by Objective-C, Ruby, Scala and C #.

to read it →
2017.06.15

I was being hugely productive on my latest and greatest project, when I decided to profile my code generation. The fact that most of my methods compiled under 6 milliseconds, but some layout methods were taking 20 or more milliseconds really irked me.

to read it →
2017.06.15

There’s never been a better time to get proficient at Apple’s open-source programming language!

Make School’s Summer Academy focuses on teaching iOS development with the Swift programming language because of the doors it will open in students’ lives and careers. Here are a few reasons that make us excited about Swift:

1. Swift is the premiere language for building iOS apps, and it’s here to stay!

to read it →
2017.06.15

In this tutorial, I'll show you how to use a powerful yet elegant on-device database solution for your iOS apps: Realm Mobile Database. An alternative to Apple Core Data or SQLite with object-relational mapping (ORM), Realm Mobile Database offers developers an easier and more natural way to store and query data.

What Is Realm Mobile Database?

to read it →
2017.06.15

We’ve seen how adapter pattern with Swift in our last coding.

But, can we achieve the essence of Adapter Pattern w/o writing Adapter classes Answer is Yes, but before lets discuss “why” i.e. the motivation.

to read it →
2017.06.15

AppleScript is a great technology on macOS for both developers and power users. It allows users to create automated processes which work other apps. As a developer though, sometimes you want a build an app in Xcode with the power of AppleScriptwithout the need to have separate script files.

To work with AppleScript in any app, there are two options to do this...

to read it →
2017.06.15

If you want to separate your integer values into groups separated by a character (i.e. 1.000, 1 000 000) then you need to use NumberFormatter.

What is NumberFormatter? NumberFormatter is a formatter that converts between numeric values and their textual representations.

How to use it...

to read it →
2017.06.15

iOS 10 brought with it a new set of API and a powerful notification system revamp that let developers and marketers alike create really engaging experiences for users. Apple allowed the ability to do custom UI on a notification (such as Calendar or iMessage) and even prepare content for download and display, such as tweet attachment previews.

iOS 11 doesn’t bring with it too many new features — but it does bring something I think is really important to users — and that’s privacy. When you think about it, the content of push notifications are typically very personal to you, and it’s not something you may want to share. This could be anything from iMessages from your partner through to fitness information through to shipping notifications. This is all data that should be, if you want, hidden until you unlock your phone.

to read it →
2017.06.15

Today we will dive deeper into multitasking. This part carries on from my last article, I recommend you start with the first part.

In Part 1, We show how to Drag and Drop work with UITableView. UICollectionView implementation is a replica of UITableView. So, let’s see How to Add Drag and Drop support to another view. We can add Drag and Drop support to almost all control of iOS which are a subclass of UIView class.

Let’s take simple a UIImageView. Apple introduce new class called UIDragInteraction.

to read it →
2017.06.15

The CoreML and Vision frameworks were amongst some of the coolest new tech announced at WWDC on Wednesday (7 Jun).

CoreML makes it really easy to integrate pre-trained machine learning models into your iOS app using either Swift or Objective C. It abstracts out various details of how the model works and lets the developer focus on just the code. CoreML even decides whether to run your model on the device’s CPU (typically for memory heavy models), or on the GPU (typically for compute heavy models) and exposes a set of easy to use developer APIs. At the time of writing, Apple also provides a tool to easily convert models built using Caffe, Keras and Scikit-Learn into a .mlmodel file that can be consumed in Xcode. Some supported model types include neural networks (feedforward, convolutional and recurrent), tree ensembles, support vector machines and liner models including linear and logistic regression.

to read it →
2017.06.15

Requirements:

  • iOS11 Beta or Later
  • Xcode 9 Beta or Later
to read it →
2017.06.14

One more thing about properties is that you can also define them on the type itself (a class, struct, enum). Useful when you want to define properties which are the same to all instances of that type.

The benefit of type properties:

  • You have access to them without needing to create a new object of that specific type.
  • These type properties area available to any instance of that particular type

Type properties can be both computed or stored properties (var or let). However, in a class, a type property which you want to be overridden in subclass, can only be a computed property. You will get this error if you try otherwise: error: class stored properties not supported in classes; did you mean ‘static’?

to read it →
2017.06.14

Localizing your app display name is actually a very simple task, so let’s just get right into it.

First, make sure you set up localization for another language (Note, this is not all that is required to completely localize an app, just the display name). Select your project in the project navigator, go to Localizations, then select a language to localize your display name for as pictured below.

to read it →
2017.06.14

I know. It’s Wednesday. I normally post on Fridays. But the Orioles are crashing and burning, so my evenings have suddenly become a whole lot less busy.

A couple weeks back, I wrote about Automatic Reference Counting and strong vs. weak reference cycles. Going over this really helped me reinforce this topic in my own head. What I was really working up to though, was this:

var someFunction: () -> String = { [weak self] in return "Hi! I'm Pat!" }

…what the hell is that? [weak self]? I’m so scared.

to read it →
2017.06.14

Yesterday, I was chatting about ways to partition a stream of values. I wanted to collect values into new streams: values that satisfied a predicate, and those that did not. A number of hugely complicated approaches were discussed until Nate Cook brought up a fantastic new Swift 4.0 API. The Dictionary type’s init(grouping:by:) call allows you to convert any sequence to a...

to read it →
2017.06.14

The paper is written by a group of researchers at Google and introduces a neural network architecture called MobileNets.

The authors of the paper claim that this kind of neural network runs very efficiently on mobile devices and is nearly as accurate as much larger convolutional networks like our good friend VGGNet-16.

So of course I wanted to find out how fast it runs on the iPhone!

to read it →
2017.06.14

At WWDC 2017, Apple released a lot of exciting frameworks and APIs for us developer to use. Among all the new frameworks, one of the most popular is definitely Core ML. Core ML is a framework that can be harnessed to integrate machine learning models into your app. The best part about Core ML is that you don’t require extensive knowledge about neural networks or machine learning. Another bonus feature about Core ML is that you can use pre-trained data models as long as you convert it into a Core ML model. For demonstration purpose, we will be using a Core ML model that is available on Apple’s Developer Website. Without further ado, let’s start to learn Core ML.

to read it →
2017.06.14

Today we will review framework under the terrible name CoreData, from Apple. I hate it so much. This is Apple’s solution to work with SQLite (a relational database). CoreData can store Swift objects in SQLite, and also it can perform the reverse operation.

I personally prefer the Realm, since you don’t need to do a lot of movements to make it work: simply install and begin to create all what you want, plus the official website has a great documentation for all features. But when you look through the vacancies of other companies (I personally never do it. Other companies… they exist? For real?!:)). Often you see, that CoreData is required, and if you do not have experience with this framework, then you can easily became «gone with the wind» at the beginning of the interview, and nobody well ever know all about those beautiful buttons you can do.

to read it →
2017.06.14

A friend of mine asked me to help her with learning auto layout on an existing app that she is rewriting and upgrading to Swift along with adding some new features. The app is an educational tool used on the Hawaiian island of Oahu to help get children interested in learning about the environment. We set about up updating many of the existing view controllers in Storyboard, adding UIStackViews and setting constraints. Most of the set up was pretty straight forward, we just needed to make sure the buttons, images and text views were properly updated for the new larger phone sizes.

One of the main focuses of the app is around the Hèeia pond, which contains sensor information that the app can display to show kids what is happening at any given moment in the pond. This was a new feature in the design and the idea was to have a series of buttons surrounding the pond to indicate the sensors located in the pond. Basically we need to arrange the buttons in a semi-circle to approximate the edge of the pond.

to read it →
2017.06.13

Apple announced Xcode 9 along with Swift 4 during the Keynote and State of the Union last week in San Jose for WWDC 2017. One of the most significant changes that made it into the Swift 4 Standard Library is a series of protocols for Encoding, Decoding and Serialization of type instances that allow users to convert to and from JSON, as well as to and from the local disk. These protocols, most notably Codable, Encodable and Decodable are intended to be the native Swift answer to several limitations that developers hit when dealing with serializing objects in Swift 3 or earlier.

to read it →
2017.06.13

Like most of the programming languages swift also contains variables and constants in which we can assign/store data. As the name suggest we use variables to store the data that may vary in future. You declare variable by “var” keyword.

var playerScore = 73

In the above example score of the players varies so we declare it as a variable.

For the values you know will never change you have to declare those with “let” keyword.

to read it →
2017.06.13

It’s so easy to open a new project, start coding and bring your ideas to life.

However I encourage you to pause for a moment. Do you think this project is likely to be something great in the future? Could you see yourself continuing on with this in a few months?

If the answer is yes, then you may benefit from structuring your project and setting it up well from the beginning.

Here are some steps that I follow.

to read it →
2017.06.13

Since I started to learn Swift, I absolutely fell in love with the concept of optionals. First I thought “Well, thats just like classes in Java. Either there is a value or its null.” but now I know better and I really enjoy how optionals improved my overall coding style.

However, in some situations, I really hate the amount of boilerplate I have to write for a simple task. For example in one of my UITableViews. They use the wonderful automatic sizing via auto layout.

to read it →
2017.06.13

1) Use Google-API SDK for your iOS app.

Start with setup in Appdelegate:

  • GMSServices.provideAPIKey (AppConstants.googleMapsApiKey)
  • GMSPlacesClient.provideAPIKey (AppConstants.googleMapsApiKey)
  • *Don’t forgot to import GoogleMaps & GooglePlaces in Appdelegate :)

2) Go to ViewController and add View over it . Change the name to GMSMapView.

to read it →
2017.06.11

At WWDC 2017, there was a great session on What’s New in Testing which was mainly about new features of XCTest and XCUITest frameworks. The team working on developer tools at Apple has made huge improvements in the area of UI Testing with XCUITest and Continuous Integration with Xcode Server. In this post, we will explore all the new features with practical examples in Xcode 9 and command line. There is Github repo Xcode9-XCTest created as part of this exploration. You can reference this post to that GitHub repository to try out the things by your own.

There are lot of new things announced related to testing for Apple platforms especially iOS and macOS. Some of them are as below.

to read it →
2017.06.11

Apple has recently announced new features in XCUITest framework. One of the great feature is Activities which can be used to organise XCTest actions into human readable activities. The new protocol XCTActivity has been added to the XCTest framework.

to read it →
2017.06.11

Swift4 and Xcode9 will be greeting you with a new warning in your existing code, popping up near areas where you are calling on Swift functions Objective-C functions. For instance, when initializing a UIBarButtonItem and including a #selector(swiftClassFunction).

to read it →
2017.06.11

Today I’m talking about attributedString in Swift.

Recently, Apple update the version of swift to 3 and almost all api and swift core standard library is modified base on API Design Guidelines but unfortunately some of are remained.

Among them, UIKit is especially used by many developers and NS prefix sometime bothering developers.

When i use UITextView in UIKit , I’m faced with the issue of NS***AttributeName . There are mainly two problems. One is all attribute value is `Any` type, so it is possible that the dealing will cause a undefined behavior. The other is all attribute name is a global value and it is not conveniently designed.

So, staring from this problems I’ve created a library that is compatible those problems.

to read it →
2017.06.11

What is the lazy keyword?

The lazy keyword allows you to delay the initialization of a stored property until it is first accessed. You can only use lazy inside a structure or a class.

// Compiler spits out an error if you try to use lazy on properties outside of a struct or class: lazy is only valid for members of struct or class

Why would you want to use it?

to read it →
2017.06.11

At WWDC 2017, Apple introduced a simple way for developers to add AI capabilities to their iOS application with Core ML. This can be used in a variety of domains like object detection, sentiments analysis, handwriting recognition, music tagging, etc. All this can be integrated with only one single file called Core ML Model and couple lines of code.

to read it →
2017.06.11

Hey! Switch between VC is really important for every application. You can swich between VC with three options :

  • Segue
  • Present ( Programmatically )
  • Push ( Programmatically )
to read it →
2017.06.11

WWDC 2017 has made one thing very clear: Apple is going all in on machine learning on the device.

And they want to make it as easy as possible for app developers to join them.

Last year Apple announced the Metal CNN and BNNS frameworks for creating basic convolutional networks. This year we get lots of additions to Metal, a new computer vision framework, and Core ML: a toolkit that makes it really easy to put ML models into your app.

to read it →
2017.06.11

Q 1.8 Write an algorithm such that if an element in an MxN matrix is zero, it’s entire row and column are set to zero.

to read it →
2017.06.11

Do you ever work with a UIStackView and think “Jeez, this vertical stack view looks really good on portrait, but looks like a disaster on landscape. If only I could make it vertical on portrait BUT horizontal on landscape…”

Well, this tutorial is for you!

to read it →
2017.06.11

This post is a brief introduction about common design patterns in Swift. In future post, I will go deeper into the most common and frequent design patterns.

As developers, the most common questions around design patterns are:

  • What is a design pattern.
  • Why and When you should use it.
  • How to use it and Where is it appropriate.
to read it →
2017.06.10

Every so often I come across an amazing feature in Swift that leaves me astonished. I wonder how I had not come across it sooner. Discovering Swift’s defer statement was one of those times.

The idea behind defer is simple: anytime you want to ensure a block of code is called before exiting your current scope, simply place the block of code inside a defer statement.

to read it →
2017.06.10

When building something, pending on the complexity involved, I feel the need to map some types of objects to other types. A very common example is mapping CoreData specific objects to simpler plain objects that you can use throughout the project and maybe even reuse elsewhere cutting dependencies.
Not a difficult task, can be achieved by different approaches but I suffered the lack of something that could help me to keep the code organised.

to read it →
2017.06.10

In a previous article we discussed how to reuse views using container views and storyboard references. The example we worked with consisted of a single reusable view (with a centered label) which we included several times in a container view. The view’s dimensions automatically adapted to the container’s but the contents of the label remained the same for each instance.

So how do we customize the view so that each instance can have a different label text. First thing we need to do is create a custom view controller class for the reusable view. I named mine ReusableViewController (don’t forget to assign the class to the storyboard object using the identity inspector). The controller will have an outlet to the label object and a text instance variable.

to read it →
2017.06.09

In this first post I will introduce Computed properties and how to use Getters and Setters, as an attempt to put on paper what I learn while i go through the Swiftlang features.

There are a few important things which are useful to know about before jumping in...

to read it →
2017.06.09

When it comes to reusing views many suggestions involve creating XIB files, extending the UIView class and overriding multiple initializers to load the NIB resource programmatically. There is a simpler alternative that only deals with storyboards and requires no coding whatsoever.

To get started drag a Container view from the object library and drop it inside the parent view. The container comes complete with a blank view that will serve as a slate for designing our reusable component.

to read it →
2017.06.09

Foundation’s URLQueryItem is just a stringly-typed key-value pair. You create one with a name and value: public init(name: String, value: String?) Since Swift supports literal initialization, you’d think you could use a dictionary to set up a [URLQueryItem] array, right? Well, yes and no. You can’t just conform Array where Element == URLQueryItem to ExpressibleByDictionaryLiteral. Array extensions with constraints...

to read it →
2017.06.09

Considering I cannot buy a lot of the new gadgets that Apple is advocating I will be discussing some of the updates that are coming to Swift 4 that I am excited about. If you have an apple developer’s account feel free to download the new beta version of Xcode, which will allow you to play around with Swift 4.

to read it →
2017.06.09

Today I’m going to talk about how to change your app icons on the iOS home screen. So you might ask me, what are the use cases for this feature? You may personalize the app icon to each individual user, the icon itself can deliver useful information at a glance depending how you customize it. As for me, one of the tasks for my internship project is to implement this feature so that clients of each comic can have the option to display their particular comics on users’ home screens. This will not only provide value to our clients, but provide value in our app and allow users to select an alternate app icon.

to read it →
2017.06.09

Localizing your iOS / macOS app name is actually a really simple task, so let’s just get right into it.

Creating a Strings File.

If you do not already have one, go to File > New > File, and select the Strings file template located under the Resource tab as pictured below. Also, if you have not localized your Info.plist file, click the Localize button in the right hand pane.

to read it →
2017.06.09

CoreMLTools are a great set of tools to make use of any neural network in Cocoa Frameworks (iOS, macOS, tvOS, watchOS). It allows you to convert your well trained (or well searched on google) neural network to a format that Apple OSs (Oses? Oss?) will understand, but most of all, will exploit lightning fast on Apple devices.

I have struggled a lot to make this works, not because coremltools is hard to use, but because python on macOS is a mess.

So long story short, here is the solution : You need to create a virtual env with Python2.7 on macOS running the right version of everything, to make coremltools actually works.

to read it →
2017.06.09

Apple has introduced several new cool frameworks at WWDC 2017.

ARKit — a framework that provides APIs for integrating augmented reality into your apps.

Core ML — provides an API where developers can provide a trained model, some input data, and then receive predictions about the input data based on the trained model.

Vision — a framework to apply high-performance image analysis and computer vision techniques to identify faces, detect features, and classify scenes in images and video.

And much more new frameworks and improvements to exist frameworks.

In this tutorial I am going to focus on Vision framework.

to read it →
2017.06.08

How to build scrolling stack container and keep an healthy usage of the memory.

In these days mobile UIs became a complex job; lists (tables or, more often, collections) may contains heterogeneous groups of items, showing in a single scroll interaction a great amount of data.

Take for example the IMDB application; the home page contains...

to read it →
2017.06.08

Starting in Swift Playgrounds 2, you can now use localized strings to guide the narration of your interactive lessons. As the screenshot above demonstrates, you can used localizable markup to provide the most appropriate text for titles, introductory text, and feedback. However, what you can’t do is localize Swift members. Your French and Chinese consumers...

to read it →
2017.06.08

This is ultra short tutorial on how to export OpenStreetMap map view into 3d model for ARKit. I will try to keep it as simple and quick as possible :)

to read it →
2017.06.07

Yes you heard it right, Wireless Debugging. We were waiting for this moment and finally Apple announced wireless debugging feature on Xcode 9 at WWDC 17.

First lets look at how Apple introduce this feature on their website...

to read it →
2017.06.07

Apple’s Famous Framework Has New Toys.

Craig Federighi, colloquially referred to as #HairForceOne among the Apple faithful, pulled off the curtains on iOS 11 no less than 48 hours ago. It’s no surprise we’ve got new APIs to dig into, and if the iPhone received some modest love this year — the iPad may have well been proposed to.

While it’s fresh in my mind, here are just a few nifty additions that caught my eyes while browsing the diffs, in no particular order.

to read it →
2017.06.07

In this post is going to cover how to implement the caesar cipher with a little twist. The encryption functions we are going to build will take two parameters. The first parameter

to read it →
2017.06.06

Introducing Shallows — a reusable, easy-to-use caching library

I think you would agree that sometimes in iOS things that should be easy are made hard. Okay, not hard, but cumbersome, unintuitive, and absolutely no fun.

One of the good examples is a lightweight persistence. Maybe you want to save a small amount of user data on disk. Or cache some information that came from the web. Maybe you even want to store images. You know that these things are kinda easy to implement, but you rather not.

to read it →
2017.06.06

From Rick Ballard, Swift Package Manager release manager, a status update with regard to Swift 4. Here’s an overview of the proposals that have recently been incorporated into the system: We’ve implemented a number of evolution proposal[s] this Spring...

to read it →
2017.06.06

iOS 11 was announced in WWDC 2017 and available to download now. One of the most inspiring features is to leverage machine learning in different levels. The direct advantage for our developers is Core ML. In this article, I will introduce Core ML with an example to detect objects in image.

Simply speaking, there are two phases in complete machine learning development: training with large-scale data to get model and use model to predict with new input data. Core ML works in the second phase.

Here is a simple figure to depict the complete process.

to read it →
2017.06.05

Tim discusses using Swift enumeration indirect keywords to build binary tree nodes. Read on to learn more about how reference types and value semantics combine… Today we’re writing a simple binary search tree in Swift. While binary search trees seem to be very powerful in theory, their performance is rather disappointing in practice. Other, more advanced tree-shaped data...

to read it →
2017.06.05

This a game development meets iOS development post.

I spent about 3–4 years making games as a hobby. Made many small games thanks to game jams like: Ludum Dare, JS13k games, among others. At some point even made a “larger” game that is available in the app store for free. (Mammoth Monkey Mole is a puzzle game made entirely in SpriteKit and Swift. )

At that time I didn’t want to learn Unity3d which was not as friendy for 2D games as it is now. Neither I wanted to make a Javascript web wrapper or use another cross-platform game engine. As an iOS developer I thought I could release faster by using tools I already knew. I was already familiar with Xcode and Obj-c, I just had to learn SpriteKit.

to read it →
2017.06.04

Swap is cumbersome without tuples. You declare a temporary constant to whose value you set the value of an input. You set the value of an input to another input. You set other input value to the value of the temporary constant. It so many steps that it is hardly legible. Isn’t there an easier way?

to read it →
2017.06.04

Generics is one powerful feature of swift that allows us to work with generic types. In this article, we’ll cover what generics are, and how to use them in your project.

You must have come across the term ‘generics’ when working in swift. They’re those funky things in angle brackets. What generics give us is the ability to use a generic type. You probably have a couple of methods that are almost identical, the only difference is in the parameter type and the return type. Old school programmers will remember function overloading. Well, with generics, you can write one function that you don’t need to overload, and that accepts generic types and returns a generic type.

to read it →
2017.06.04

Apple made Swift open-source in December, 2015 and since then new version of Swift getting released frequently. In these changing environment of Swift development, it’s essential to make sure version of the Swift being used to build iOS apps are correct and as expected. We will cover how to automatically check version of Swift using Fastlane plugin I wrote called ‘ensure-swift-version’.

to read it →
2017.06.04

Grand Central Dispatch (or GCD for short) is one of those fundamental technologies that most Swift developers have used countless times. It’s primarily known for being able to dispatch work on different concurrent queues, and most of you have probably used it to write code like this...

to read it →
2017.06.04

The deployment of an iOS app to iTunes Connect involves various things and it’s time consuming and fragile activity. It’s very common practice for iOS developers use Xcode to build, test, archive and upload app to iTunes Connect. Fortunately Apple has command line tools to do all this things and one of the most popular utility is xcodebuild. There is fancy wrapper on Apple Developer tools called Fastlane which can be used for scripting deployment of an iOS application. You might be wondering why we need to use command line to deploy iOS application. Can you imagine a day without Xcode ? Or Can you think of deploying an app from server where you don’t have GUI access? Or What if you don’t have scripting skills in Ruby to use Fastlane?

to read it →
2017.06.04

In a previous post I discussed strategies for using singletons in a cleaner, more modular way. Singletons are a fact of software development, especially in iOS. Sometimes the design pattern actually is the right tool for the job. In those situations, how we can improve the way we write our own singleton classes?

to read it →
2017.06.03

In these series of article, I’ll try to implement the magical Protocol Oriented Programming and will see how it can refactor our codebase to look awesome and work flawlessly.

to read it →
2017.06.03

Hi there. This is the second guide in my series called “_ in 10 minutes or less” and I will be covering a little bit of MapKit and CoreLocation today. Today we’ll be creating a simple app that will retrieve a bunch of nearby restaurants and display their location on a map. Let’s begin!

to read it →
2017.06.03

Automatic Reference Counting (ARC) is a memory-management implementation in the Clang compiler for the Objective-C and Swift programming languages.

In old times before the release of ARC, memory management was solely dependent on developer with the use of release and retain messages with which objects can be be marked for deallocation and retention.
So, system automatically delete objects when they are longer needed based on reference counting.

to read it →
2017.06.02

In this Swift Algorithm Club tutorial, you’ll learn how to implement a heap in Swift 3, a way to implement a priority queue.

to read it →
2017.06.02

What is a function? A function is a set of steps that performs a specific task. A function is a type of procedure or routine that you use through your programs so that you don’t have to repeat yourself.

Lets just get to writing one and I will explain things along the way.

to read it →
2017.06.02

Any app that saves the user's data has to take care of the security and privacy of that data. As we've seen with recent data breaches, there can be very serious consequences for failing to protect your users' stored data. In this tutorial, you'll learn some best practices for protecting your users' data.

In the previous post, you learned how to protect files using the Data Protection API. File-based protection is a powerful feature for secure bulk data storage. But it might be overkill for a small amount of information to protect, such as a key or password. For these types of items, the keychain is the recommended solution.

to read it →
2017.06.02

Kotlin This name is in news from last week and reason is Google announcing it as its officially supported language on Android at I/O 2017 Developers conference.Although Kotlin is not a replacement for Java or C++ support but only an additional language still I found that it adds a lot of nice-to-have features that Java doesn’t currently support.

Before disclosing it identification with swift lets know a bit more about Kotlin.

to read it →
2017.06.02

I know Swift… I know SwiftjQuery21307311304953965099_1496814865281?

Below are the questions which came up in my mind while learning Swift, so i thought it would be good to share what i learn…

Questions(Swift Only)...

to read it →
2017.06.02

For several of the projects I’ve worked on, we’ve used third party code generation libraries for server models and a lot of times, the properties on those server models have been optional. Every time you want to initialize an enum with that optional, you have to first unwrap it before passing it in as a rawValue.

Every time was the key part there. Sounds like duplicated code. We can easily reuse this code by making an extension. You can only initialize an enum with a rawValue if the enum conforms to RawRepresentable.

to read it →
2017.06.02

The patterns to convert an instance is discussed when conversion from a Resource instance to MutableURLRequest instance is required.

There are two ways to do it.

to read it →
2017.06.02

Today I was striving to insert some left and right margins to table view cell implementation that I’ve done, first of all, I tried to search something on Google, and so, nothing solve my problem, but I could join some ideas, and finally, I got a solution. Notice on the image above, my UIViewController has a blue color, and my table view is transparent, it is important to see the background color of UIViewControler must be different from the background color of your content view cell, so in this way, we can realize the effect.

The first step, we need to extend the UITableViewCell to custom the insets of our content view, this is showed in the code below...

to read it →
2017.06.01

When building your app it’s essential to think about the way content will be displayed to the user. Separating functionality and logic into different view controllers keeps things clean both for the user and in your codebase. While Apple offers ways to navigate to these view controllers with a UINavigationController or UITabBarController sometimes they don’t quite fit the needs of you app.

In this post I’ll build a simple app that demonstrates how to create a navigation interface. It will involve creating a master view controller that will be in charge of presenting and dismissing other view controller views based on user actions.

to read it →
2017.06.01

Today I was required to do a batch update using an API service, a simple JSON listing that ended up into an array of keys to update. The array was just around 1k records.

I have been playing more and more with Swift the last days and decided to create a simple script inside a Playground with it…but… it was taking around a minute just to create an array of 1k items.

Started to do some cleanup and ended up realizing something interesting:

Here is my test playground...

to read it →
2017.06.01

We can declare variable in 2 ways:

1)Optionals “there is a value, and it equals x” or “there isn’t a value at all i.e nil”

2)Implicitly Unwrapped Optionals “there is alway value for it ” or “If value is nil then RuntimeError”

Example...

to read it →
2017.06.01

I’m a bit behind blogging this week — I had family staying with us for the week to see the baby, which threw off my Swift schedule! But here I am back at it. The Swift Programming Language covered Collection Types and Control Flow in the next hundred or so pages I read, and I thought I’d use this blog post to take a closer look at the difference between basic while loops and repeat-while loops, which are both types of control flow.

So what IS a while loop?

to read it →