Category: Programming
How to record and play sound in Swift
In this tutorial, we are going to see the required steps to record and play sound in Swift Programming language using AVAudioRecorder and AVAudioPlayer Download source code from github (SoundController.swift) User Interface The user interface for this demo is simple with two buttons, one for recording and another for playing sound. Create corresponding IBAction and…
UITextFieldDelegate in Swift
This is a beginners tutorial on UITextFieldDelegate in Swift. We are going to see how to use UITextFieldDelegate by writing a Simple Interest Calculator. Download the source code from here This calculator uses UILabels and TextFields for displaying and accepting amount and interest. We are going to use the UITextFieldDelegate method to navigate from “Principal…
SplitViewController example in Swift
This is a beginners tutorial on SplitViewController using Interface builder with programming language as Swift. There are also some good articles available on SplitViewController, check them out as well – nhipster and whoisryannystrom. Create a new Single View Application. Choose Language option as Swift and provide a product name. Navigate to Main.Storyboard and select default…
payworks SDK integration in Swift
payworks mPOS helps app developers to integrate their App with card reader. In this tutorial, we will see a sample app that integrates payworks mPOS using Swift. Download the source code from github Select New Project and choose Single View Application from the template. In the Project Options window, provide a product name and make…
Debugging Swift App in Xcode
Any beginner iOS developer should be aware of the NSLog statement. This is quite frequently used to debug Objective-C programs. In Swift you can use println or print statement instead of NSLog to write the debug information to the console log. [code language=”swift”]var primeFlag:Bool = true println("input number is \(number)") if ((number == 2) ||…
Test Driven Development in Swift
Here is a beginner tutorial on TDD in Swift by writing a program that checks for a prime number. Let us start by creating a new project, selecting template as Single View Application. Though we won’t be adding anything to the storyboard as we will focus only on the business logic. After creating the project,…
Swift Enums
Enumerations, or enums, are a powerful feature in Swift that allow you to group related values under a single data type. Swift enums have significantly more capabilities compared to their counterparts in many other languages, including Objective-C. Let’s explore the various features of Swift enums with examples. Basic Enum Declaration Here’s a simple enum representing…
Swift Tuples
Tuples in Swift are a powerful feature that allows you to group multiple values into a single compound value. They’re particularly useful for returning multiple values from a function or for temporarily grouping related data. Let’s explore how to use tuples effectively in Swift. Basic Tuple Usage At its simplest, a tuple can group two…