Skip to main content


Showing posts from June, 2019

Swift Higher Order Functions Filter, Map, Reduce, Flatmap and CompactMap

Map, filter, reduce, Flatmap and  CompactMap drop in Swift. Simple Higher Order Function Higher order functions are simply functions that operate on other functions by either taking a function or closures as an argument, or returning a function. That can be used on collection types such as Array or Dictionary Map : - " Use map to loop over a collection and apply the same operation to each element in the collection. The map function returns an array containing the results of applying a mapping or transform function to each item:" That used for-loop-  let arrays = [2.0,4.0,5.0,7.0] var arraySquar: [Double] = [] for value in arrays {   arraySquar.append(value*value) } // [4.0, 16.0, 25.0, 49.0] Now With map let arrays = [2.0,4.0,5.0,7.0] let arraySquar= arrays .map {$0 * $0} // [4.0, 16.0, 25.0, 49.0] let scores = [0,28,124] let words = { NumberFormatter.localizedString(from: $0 as NSNumber, number: .spellOut) } print(words) // ["ze

Parse XML in iOS with Swift 4.0 with A SOAP Web Service Apple RSS News

A Simple XML Parsing Example in ios with Swift 4.0.  ASMX - SOAP-XML(Simple Object Access Protocol -  Extensible Markup Language ) SOAP -  Simple Object Access Protocol itis a xml-based messaging protocol for exchanging information among computer "ASMX provide the ability to build service that send message using the SOAP" SOAP is communication via internet SOAP can extend HTTP for XML messaging Data transfer for web service "XML stands for Extensible Markup Language. XML is a markup language much like HTML. XML was designed to store and transport data. XML was designed to be self-descriptive." its defines a set of rules for encoding documents in a format human-readable and machine-readable. In this tutorial parse xml web service(apple rss news - ) using a XMLParser object. The results of the parse the data in a tableView in UITableViewController. This tutorial is made with Xcode 10 and built for iOS 1

Check for internet connection in iOS App Swift

Check Internet Connection if you are going in your application, Your Connection are Cellular & WIFI are ON/OFF. First your create a Network swift class then implement where are you check connection on/off let start:- a  create public class Reachability  import Foundation import UIKit import SystemConfiguration public class Reachability {          class func isConnectedToNetwork() -> Bool {                  var zeroAddress = sockaddr_in (sin_len: 0 , sin_family: 0 , sin_port: 0 , sin_addr: in_addr (s_addr: 0 ), sin_zero: ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ))         zeroAddress. sin_len = UInt8 ( MemoryLayout . size (ofValue: zeroAddress))         zeroAddress. sin_family = sa_family_t ( AF_INET )                  let defaultRouteReachability = withUnsafePointer (to: &zeroAddress) {             $0. withMemoryRebound (to: sockaddr . self , capacity: 1 ) {zeroSockAddress in                 SCNetworkReachabilityCreateWithAddr

Nested JSON Parsing with Alamofire and SwiftyJSON in Swift 4

Build A Simple API (Custom JSON) with Alamofire & SwiftyJSON  This Full Example helps to design a UIViewController WithOut StoryBoard with a UITableViewController, Custom Cell design to show data ion to api service json, this Tutorial  helps to understand how to use Alamofire with SwiftyJSON to hit an API and fetch results, parse them and show the results in an UITableViewController. A Nested JSON :- like /*{ "id": "c200", "name": "Ravi Tamada", "email": "", "address": "xx-xx-xxxx,x - street, x - country", "gender" : "male", "phone": {     "mobile": "+91 0000000000",     "home": "00 000000",     "office": "00 000000" } } */ Web Service api -  parse the data and show result in tableView. First create pod file instal