Category Archives: Swift

Special characters that can be included in a Swift String ?

By | January 5, 2018

Special characters can be included in string literals using the following escape sequences: The following example shows how to use a few string literals: Swift 4 Escape sequence Meaning \0 Null Character \\ \character \b Backspace \f Form feed \n Newline \r Carriage return \t Horizontal tab \v Vertical tab \’ Single Quote \” Double… Read More »

How to Count characters in a String in Swift 4?

By | December 20, 2017

To retrieve a count of the characters in a string, call the global countElements function and pass in a string as the function’s sole parameter: prints “sampleString has 32 characters” Note : Different Unicode characters and different representations of the same Unicode character can require different amounts of memory to store. Because of this, characters… Read More »

How Type Safety is implemeted in Swift 4?

By | December 15, 2017

Swift 4 is a type-safe language which means if a part of your code expects a String, you can’t pass it an Int by mistake. As Swift 4 is type-safe, it performs type-checks when compiling your code and flags any mismatched types as errors. Playground execution failed: error: :6:6: error: cannot assign to ‘let’ value… Read More »

Simple Alert with two buttons in iOS Swift with callback

By | December 1, 2017

Dear Friends, Today I will show you how to create a simple alert with two buttons and how to write a callback for each button. The code is simple. Its written for Swift 3. Send your comments to coderzheaven@gmail.com

Class has not initialiser error in Swift – Solved.

By | August 14, 2017

Apart from other languages, when you write a class in Swift, It should have a initialiser. To solve this we have to write init() function in that particular class. Just like below. For example, look at the below class. Here we have 5 variables. The above error usually comes when you don’t initialize all variables… Read More »

Custom TimerView in iOS – Swift

By | April 10, 2017

Hello everyone, Here in this tutorial I will show you how you can create a Custom View for Timer without any layout in Swift. Custom Timer Class Our Custom timer class will look like this Here I am passing the superview in which timerview is going to be placed as the parameter. Then I am… Read More »

Core Image Tutorial in Swift

By | March 30, 2017

It allows developers to filter images in their apps. Advantages Core Image supplies 90+ filters. Powerful image filtering capabilities Core Image includes APIs for face detection Automatic image enhancements Custom effects through “chained” filters. You can get all kinds of effects, such as modifying the vibrance, hue, or exposure. It uses either the CPU or… Read More »

How to record Audio using AudioRecorder in iOS Swift

By | February 10, 2017

Well, its really easy for recording audio in an iOS application. We will decalre two variables in our View Controller Request Permisson from the User Start Recording Set Delegate Finish Recording Note : Sometimes iOS Stops the recording when a phone call comes. In that case we need to handle this. Since the delegate is… Read More »

Error Handling in Swift

By | October 1, 2016

When calling a method that may cause a failure, you normally pass it with an NSError object (as a pointer). If there is an error, the object will be set with the corresponding error. You then check if the error object is nil or not and respond to the error accordingly. That’s how you handle… Read More »

Custom TableView in iOS Swift

By | August 6, 2016

In this post we will see how we can create custom tableview cells in Swift. Let’s Start… Create a new project and name it the way you like. For creating Custom TableView we have to do below things 1. Drag a tableview and Drag a UITableView Cell into it. 2. For our example – Drag… Read More »

What are optionals in Swift ( ? && ! ).

By | June 30, 2016

Swift introduces Optionals type, which handles the absence of a value. Optionals say if there are set a value, then take that value, it can be of any type AND else it is nil. Basically It has two possible values, None and Some(T), where T is an associated value of the correct data type available… Read More »

Using NSOperationQueue in iOS to do Serial/Concurrent Operations.

By | May 7, 2016

NSOperationQueue is used to do scheduled operations in iOS. You can customize NSOperationQueue to do Concurrent/Serial operations. You can set NSOperationQueue maxConcurrentOperationCount to tell it to do how many operations to execute at a time. Lets see this with an example [Swift Version] In the above example, we set maxConcurrentOperationCount to 1, telling it to… Read More »

Contacts Demo in Swift 2 – Showing Contacts Picker, Load Contacts in Custom TableView, Add New Contact, Update Contact, Delete Contact, Search Contact

By | February 23, 2016

In Today’s post I will show you How to do below things in Swift 2… 1. Show Contact Picker using System In-Built UI & Pick a Contact 2. Load all Contacts in a TableView 3. Search a Contact 4. Add a New Contact 5. Update a Contact 6. Delete a Contact Before using the contacts… Read More »