Skip to main content


Control Flow Statements - statements used in swift

List out what is the control transfer statements used in swift
Control flow statements are used to control the flow of execution in a program. There are several types of control flow statements in Swift, including loop statements, branch statements, and control transfer statements.  1.Loop statements allow a block of code to be executed repeatedly 2. Branch statements allow a certain block of code to be executed only when certain conditions are met 3.Control transfer statements provide a way to alter the order in which code is executed. 4.Swift provides a do statement to introduce scope, and catch and handle errors, 5.Defer statement for running cleanup actions just before the current scope exits.

Loop Statements -
Loop statements allow a block of code to be executed repeatedly, depending on the conditions specified in the loop. Swift there are three loop statements ·For-in statement ·While statement ·Repeat-while statement A for-in statement allows a block of code to be executed once for ea…
Recent posts

Enum & Enumeration in Swift 4

An Enum & Enumeration consists of integral constants

"An enumeration is a user-define data type which consists of a set of related value" Is used to define enum keyword" 

enum type { const1, const2, const3, .......}
enum week {
          case Monday
          case Tuesday
         case Sunday
Swift Example :- enum Country {
   case India
   case America
   case Russia
   case Chaina
var power = Country.America
power = .America
switch power {
   case .India:
      print("India Country is No 4")
   case .America:
      print("America Country is No 1")
   case . Russia:
      print("Russia Country is No 2")
   case . Chaina:
      print("Chaina Country is No 3")

Output is America Country is No 1

Rest Api in swift 4 Using URLSession And JSONSerialization Xcode 9 Example

A Short Example call Rest Api with JSON Foundation framework NSURLSession and NSJSONSerialization -

Getting Started - Basic Rest API request with Swift 4

func restApiRequest(){
let sessionConfig = URLSessionConfiguration.default
// Session Configuration
        let sessionUrl = URLSession(configuration: sessionConfig)
// Load configuration into Session
        let url = URL(string: "YOUR URL STRING")!
        let task = sessionUrl.dataTask(with: url, completionHandler: {
            (data, response, error) in
                if error != nil {
                } else {
                    do {
                        if let json = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? [String: Any]
                    } catch {
                        print("error in JSONSerialization")

iOS MapKit Tutorial: Getting Started Search Location and Directions on Mapkit

MapKit is a really useful API available on iOS devices that makes it easy to display maps, user locations with locality, and even draw routes your location to your destination.
Getting Started User Location
Create a new project single view appplication in Swift. - MKLocationMap

Open Info.plist from the Project navigator and configure the location permission prompt message NSLocationWhenInUseUsageDescription
Add "NSLocationAlwaysAndWhenInUseUsageDescription" instead of "Privacy - Location Always and When in use usage description".

import UIKit import MapKit
protocol HandleMapSearch { func dropPinZoomIn(placemark:MKPlacemark) } class ViewController: UIViewController{ let locationManager = CLLocationManager() var resultSearchController:UISearchController! var selectedPin:MKPlacemark? @IBOutletvar mapView: MKMapView! overridefunc viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. locationManager.delegat…

How to Get Started Firebase UI Auth Provider Swift 4 iOS

I am starting a tutorial how to install a firebase Authentication in iOS Swift application and how to use Firebase UI Auth. You can use Firebase Authentication to allow to users different type login your application or sign In / sign Up  with including email id or password, with facebook login, twitter, Gmail, pinterest or more social account authentication. This blog post help you started, how to start firebase UI auth.

Create a account firebase Console. If you have a Google account already then you are active only firebase consoleOpen and go to seen right side - GO TO CONSOLE
Click add project -> Type project name and if you mind customize project id and select your country code then accept term or condition create project. NextGo to dashboard overview and select your app platform.
Now if you add ‘Add Firebase to your iOS app’, Then Copy your bundle ID past after type your nick name did you like, This is the bundle identifier of your Xcode project. Like …

Facebook Login - Facebook Authentication and Cocoapods

Create a new application facebook login and authentication a facebook user using their iOS SDK with Cocoapods. Below are the steps in which we'll be following: First Getting Started guide from Facebook's iOS SDK Documentation Create a new iOS project Swift

Open facebook Developer Account and create new App after go to setting and click basic -> add platform ios Then add Bundle id your ios project like com.xxxx, Configuring Facebook with Bundle ID Then go ahead Download facebook sdk for ios other wise install pod file your project.
Go ahead to open terminal and go ahead your project folder.

Got create podfile -> pod init
Open podfile -> open podfile Paste ->  pod 'FBSDKCoreKit' 
               pod 'FBSDKShareKit' 
               pod 'FBSDKLoginKit' podfile and save

Then go to terminal or install podfiles -> pod Install

Enabling Facebook's Authentication Mech…

Change the Color of the Status Bar - StatusBarStyle Tutorial in Swift

How to Set Status Bar Style Color in Swift  The status bar can have a dark and light appearance inside your app In this tutorial the appearance of the status bar color will be changed try two type. This tutorial is made with Xcode 9 and built for iOS 11, swift 3 & swift 4.

1:- iOS 11 and Swift 4, Xcode 9

      Info.plist - add row View controller-based status bar appearance and set it to NO      In file appDelegate.swift -> didFinishLaunchingWithOptions in       UIApplication.shared.statusBarStyle = .lightContent  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:   [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    application.statusBarStyle = .lightContent // .default     return true }

2:- Add With a function =>Go to the ViewController.swift file and add the following lines of code.    override var preferredStatusBarStyle: UIStatusBarStyle {                       return .lightContent                 }

Design Patterns on iOS using Swift

Design Patterns on iOS using Swift - Singleton Design Pattern Example
iOS Design Patterns Tutorial - Design patterns are evolved as reusable solution to the problem that we encounter every day of programming
Types of Design Patterns - iOS Developer Live
Creational: This type design deals with the object creation and initialization.    Eg: Singleton, Factory, Abstract Factory.
Structural: This type design pattern deals with class and object composition Eg: MVC, Decorator, Adapter, Bridge, Facade.
Behavioral: Deals with the communication between classes and object    Eg: Observer, and, Memento

Creational Pattern - Singleton Design Patterns Creational Pattern - Only one Instance of a particular classes, singleton pattern belongs to Ceational type pattern, This pattern is used when we need to ensure that only one object of a particular class need to be created. Only one object available across the application in a controlled  Declaring all constructor of the class to be privateProvide static met…