Featured
-
Swift Programming Basics for Beginner - A 10 Min Video Tutorial
As we all are aware that Swift is new programming
by sandeep.rawat
Tags
Animating images in ImageView
ImageView can be used for animation with a set of multiple images using various properties offered by apple.
Here are I’m going to tell you steps to animate images in ImageView:
1- Initialise an array of UIIm...
NetworkReachability Listener in Alamofire
Alamofire provides a method to check network status reachable on WWAN, Ethernet and wifi. The NetworkReachabilityManager class provided by Alamofire listens whenever there is a change in network.
It can be used to determine background informat...
Adding Properties to Attribute Inspector in Swift
Accessing properties via interface builder is quite easy and more developer friendly.
Here I’m guiding you how to to add new/custom properties to interface builder.
1- Subclass any UIObject, we are considering here UIButton ...
Function inside a function
Functions are small modules or chunk of code. Swift’s function syntax is so flexible that it allows to write a function inside a function.
Here is a syntax:
func firstFunction(arguments) -> returnType{
func secondFunction(arg...
TextToSpeech API provided by Apple
Apple has provided a powerful api to play audio from text and here are the steps to achieve:
1- Import AVFoundation framework
2- Initialise AVSpeechSynthesizer(as below)
let synthesizer = AVSpeechSynthesizer()
...
How to cancel all request from Alamofire
Hi Readers,
If you are using Alamofire framework to implement API service classes and you need to cancel all the request which are fetching data from server. You can use following Swift code snippet:
if #available(iOS 9.0, *) {
...
How to filter array in Swift
Hi Readers,
In iOS app many times we have to filter our results according to requirement. We can filter array of results same as following example. Let say we have an array(articleArray) like:
(
{
Read = 0;
Save...
Open Date picker on textField begin editing in Swift
To open a date picker in textFieldShouldBeginEditing we can use the inpuView property of the textField.
To open a datePicker when text Field start editing we can follow these steps.
1- On your View Controller add a view that contains the our ...
Create a textField with left Side image and bottom border line in swift
1- Create a new class subclass of UITextField.
2 -Write down code below in new created class
3- Add a textField in ios Your viewController.
4- Chnage th class of your TextField with the new class that you created.
5- Change the attrib...
UiSplitView Controller in Swift
To Create a SplitViewController in swift follow the steps:-
1- Create a new Project.
2- Add a splitViewController.
3- Create a cocoaTouch Class inherits from UIViewController named as DetailViewController
4- Create another CoCoatouchC...
Show a pdf file in ios WebView in swift
Hi to load a swift file in webView in ios :-
1- Add a WebView in your viewController
2- Create an IBOutlet for this.
3- set the delegate fro webView.
4- if you want to load the pdf from server or from an url use the function loadFromU...
Create a extension class in swift of singleton
Hi,
To Create a extension class in swift Please follow the steps below.
1- Add a new Swift file in your project and add the following code
import Foundation
//MySingltonClassSwift is a singletonClass or you can use any class for which...
Create a Singleton class in swift
Hi,
To Create a Singleton class in swift follow steps below:
1- Add a Cocoa Class file subclass of NSObject named it as MySingleton and now write down the code as .
import UIKit
class MySingleton: NSObject {
static let ...
Unwind to ViewController in swift
To Use Unwind Segues in swift please follow the steps:-
1- Create two ViewController using storyBoard
2- Create a segue from FirstViewControleller to secondViewController
3- Write a function in FirstViewController like this
@IBAction func...
How to shuffle an array
Hi all,
Shuffling an array means randomly re-arranging the content of an array .Shuffling algorithm can be used in many places now days like in card games, music player , media player etc.
Shuffling of an array can be done in two ways.
...
Tic-Tac-Toe
Hi all,
Tic-Tac-Toe is simple game in which you will try to mark your sign in three blocks to make a row , column or diagonal.
RULES FOR TIC-TAC-TOE
1. The game is played on a grid that's 3 squares by 3 squares.
2. You a...
A simple function returning UIColor from HexaColor String in swift
Here are step-by-step guide to obtain UIColor:
1- Firstly you need to do is to remove all spaces and new line character sets from the string and then covert the string to UPPER Case example AABBCC.
var cString:String = hexColorString.stri...
AVAudioPlayer implementation in Swift
An easy to implement simple swift class working on AVAudioPlayer depicting various features like play, pause and stop.
// creating single instance of class
static let sharedInstance = MyAudioPlayer()
var myAudi...
Protocols in Swift
Hi All,
Protocol : - A protocol defines a representation of methods and properties that suit a particular task or piece of functionality. The protocol can then be adopted by a class, structure, or enumeration to provide an actual implementatio...
Convert String to NSData and NSData to String Swift
Hi All,
In coding we have secure some information while we are sending it to server and vice versa ,In this case we use encoding and decoding . You can encode your information by using any method of encoding and when you will receive informati...
Fetch Phone Contact Using Contacts Framework
Hi all,
Apple has introduced new Contacts Framework in iOS 9, which replaces the AddressBook framework. Accessing contacts information using AddressBook framework was very tough task for developer. But new Contacts framework of iOS 9 provides ...
One Way Binding In Swift
Hi All,
One Way Binding :- In one way bindings, data flows only from object to UI and not vice-versa. For instance, you can have a UITextField called as nameTF which is binded with an object having property nameValue. So when the object value...
How to print without newline in swift 2.0
Hi Readers!
In swift 2.0, print() statement adds a new line character automatically, where as in swift 1.2, println() and print() were 2 separate functions.
Apple in 2.0 has given only 1 statement for print() with different parameters.
T...
How to declare Sets in Swift
Hi Readers!
Let us first understand what Sets means.
Sets
A set stores unique values of same type in a collection with no ordering. Sets should be used when there is no defined order, such as in Array. Secondly Array can store multiple ...
Fetch the user detail from facebook in iOS 9.0
To fetcht the user detail from facebook like name,first_name,last_name,middle_name,gender etc use the code below :
func fetchUserDetails(useid: String,accessToken:String)
{
let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest...
login to facebook in ios 9.0
to login using facebook in iPhone sdk please use the code below.
install the pods for facebook using
pod "FBSDKCoreKit";
pod "FBSDKLoginKit";
pod "FBSDKShareKit";
pod "FBSDKMessengerShareKit"
import FBSDKLoginKit
...
Send a request using Alamofire in swift
Use the alamofire in swift first install the pod file in your project using below steps:
1- open the terminal and run following commands
sudo gem update --system
sudo gem install cocoapods
pod setup
change folder to the current proejct ...
How to use completion handler in swift
The code below will help you in declaration of completion handler and how to call the completion handler in swift.
To declare a completion handler in swift use the line :
typealias completionHander = (sucess: Bool)->Void
//decalrat...
Change the button background color when highlighted in swift
To create a button at run time in swift please use the followin code:
this code will help you in creating a button at run time. and also change the background color of the button in highlihted State..
To change the button background at the tim...
Show The Contact List in iOS
To show the list of contact in iPhone use the code Below:
1- import the ContactsUI framwork in viewController
2- Confrom the ViewController to the CNContactPickerDelegate
3- call the delegate method func contactPicker(picker: CNContactPicke...