This page contains different code snippets on how to work with Dictionary in Swift. Create Empty Dictionary // Create an empty dictionary let myDictionary = [String:String]() // Another way to create an empty dictionary let myDictionary2:[String:String] = [:] // Keys in dictionary can also be of type Int let myDictionary3 = [Int:String]()   Add Item…

Read More Working with Dictionary in Swift. Code Examples.

In this very short Swift tutorial, you will learn how to loop or iterate over a dictionary in Swift and print out key/value pairs. Loop Through Dictionary // Create a Dictionary with two elements var myDictionary = [“first_name”: “Sergey”, “last_name”: “Kargopolov”] // Loop through dictionary and print key/value pair for (key,value) in myDictionary { print(“\(key)…

Read More Loop Through Dictionary in Swift

In this Swift tutorial, you will learn how to use the flatMap function in Swift which will flatten an Array of Arrays into a single array of elements. Given Array of Arrays Let’s consider the following Array of Arrays. let numbers = [ [1,2,3,4], [5,6,7,8], [9,10,11,12]] The above array contains 3 arrays of integers. We can…

Read More How to Use flatMap in Swift. Code Examples.

In this short Swift tutorial, you will learn how to use one of the High Order Functions in Swift called map(_:) to apply a transformation to each element in an Array. Given an Array of Names Let’s consider an Array of String values: let names = [“sergey”, “michael”, “john”, “bill”, “tom”] All values in this Array…

Read More How to Use map(_:) in Swift. Code Examples.

To practice Swift programming and learn how to create and position UI elements programmatically in Swift you can use Xcode to create a new project or you can use Xcode Playgrounds. In this short tutorial you will learn how to use Xcode Playgrounds to run Swift code that creates a new UIView with a single…

Read More How to Use Xcode Playgrounds to Create UI in Swift

The below code example in Swift demonstrates how you can extend classes in Swift. Extending Class in Swift As an example, let’s learn how we can extend class Int.  Create a new Swift file in your current project and add there the following extension with a function that substructs a value. extension Int { func…

Read More Extending Classes in Swift. Class extension.

The below Swift code example demonstrates how to implement the Singleton Design Pattern in Swift. Singleton Design Pattern guarantees that only one Object of a class exists in the system even if a developer attempts to create multiple instances of it. Singleton Class example in Swift // Creating Singleton // Only one instance of this…

Read More Singleton Class in Swift. Code Example.

In Swift, a class or a struct can have multiple initializers which are used to create an instance of that particular type and set up its initial state. The code examples below show how to define a class with single or multiple initializers and how to create an instance of that class. Single Initializer class…

Read More Swift Class with Single and Multiple Initializers

I recently had to work on with one AWS service and to follow it’s getting started tutorial they invited me to use the CLI command-line interface which would configure a service for me. The CLI tool failed to configure the service itself and it did actually clear the existing ~/.aws/credentials file for me 🙁 which…

Read More Create .aws/config and .aws/credentials Files Manually

RabbitMQ docker image is available on Docker Hub. If you have docker installed on your machine, you can easily run RabbitMQ docker container using the following command: docker run -d -p 15672:15672 -p 5672:5672 -p 5671:5671 –hostname my-rabbitmq –name my-rabbitmq-container rabbitmq:3-management where: –hostname is a custom RabbitMQ host name you want to use on your…

Read More Run RabbitMQ Docker Container Command

In this short tutorial, you will learn to create a Docker image for your Spring Cloud Config Server which uses Symmetric or Asymmetric encryption to protect sensitive information. To learn how to create Spring Cloud Config that uses Symmetric encryption, read Spring Cloud Config – Symmetric Encryption and Decryption(Includes Video tutorial). And to learn how to create…

Read More Docker Image for Spring Cloud Config Server

In this tutorial, I am going to share with you how to secure Spring Cloud Eureka dashboard with Spring Security. To learn how to build RESTful Microservices with Spring Cloud by watching step-by-step video lessons, please check this page: Spring Boot Microservices and Spring Cloud. Add Spring Security to Eureka To secure Eureka with Spring Security…

Read More Secure Eureka Dashboard with Spring Security

If a requested Microservice takes long time to respond, Zuul Api Gateway might timeout and a Gateway timeout error will take place. { “timestamp”: “2019-05-24T00:53:22.152+0000”, “status”: 504, “error”: “Gateway Timeout”, “message”: “com.netflix.zuul.exception.ZuulException: Hystrix Readed time out” } In this short blog post I am going to share with you how to make your Zuul Api…

Read More Zuul API Gateway Timeout Error