How to use CommonCrypto for HMAC in Swift 4

After numerous hours trying to understand how CommonCrypto works with xCode and how to use it to generate a hmac hash, I finally made it work! In this tutorial you will see how to: What is CommonCrypto library and why to use it How to include CommonCrypto (and CommonHMAC) in your xcode project How to […]

Swift timer example – Repeat action

This tutorial will go through how to make an action repeat itself after a specific interval of time as a swift timer example. This code is written and verified on macbook pro using: XCode 8.2 Swift 3.0.2 MacOS Sierra 10.12.2 How to make an action repeat using Timer in Swift Lets understand swift 3 timer […]

Show notification in cocoa xcode app using Swift 3.0.1

This tutorial explains how to show a notification on macOS app. This code will work for a cocoa app built using xcode using swift 3.0.1. This code is written and verified on macbook pro running: XCode 8.2 Swift 3.0.1 MacOS Sierra 10.12.2 How to show notification in cocoa xcode app using Swift 3.0.1 Follow these […]

Quit Cocoa App when Window Close using XCode Swift 3

The default behaviour of XCode Cocoa Mac OS app is that when the window close button is it, it simply closes the app window. However the App doesn’t quit. Which means that the app is still running and when we try launching it again, nothing will happen. We have to manually quit the appĀ (e.g. by […]

Rounding Double in Swift

Rounding a Double in swift is quite simple and easy (tested up to swift 5.1). We simply need to use the round() function provided by swift. The example below will demonstrate how to use this function effectively, while keeping your number still a Double (without changing the type). This example has been tested in xcode […]

Stride Swift 3.0.1

Stride is an amazing and special feature in Swift (language by apple) which replaces the conventional c-style for statement loops. Stride() is used to loop over a range of numbers. This range can be moved using any increment. Lets look at three examples to understand three possible applications of stride in swift 3.0.1 code. Conventional […]