Skip to main content

Posts

Showing posts from June, 2019

Custom Loader (Activity Indicator) in Swift

Creating a custom activity indicator in Swift allows you to tailor the appearance and behavior of your loading spinner to fit the style of your app. Here's a step-by-step guide to creating a simple custom activity indicator using UIView Step 1: Create a New Swift File for the Custom Activity Indicator Create a new Swift file and name it  RotatingCirclesView.swift . Add the following code to define a custom UIView subclass for your activity indicator: // //   RotatingCirclesView.swift //   Welcome In // //   Created by Praveen Kumar on 05/09/24. // import UIKit class RotatingCirclesView : UIView {          let circle1 = UIView ( frame : CGRect ( x : 20 , y : 20 , width : 60 , height : 60 ))     let circle2 = UIView ( frame : CGRect ( x : 120 , y : 20 , width : 60 , height : 60 ))          let position : [ CGRect ] = [ CGRect ( x : 30 , y : 20 , width : 60 , height : 60 ), CGRect ( x : 60 , y : 15 ,...

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 = scores.map { NumberFormatter.localizedString(from: $0 as NSNumber, number: .spellOut) } print(wo...

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 -  https://developer.apple.com/news/rss/news.rss ) 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: ...

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": "ravi@gmail.com", "address": "xx-xx-xxxx,x - street, x - country", "gender" : "male", "phone": {     "mobile": "+91 0000000000",     "home": "00 000000",     "office": "00 000000" } } */ Web Service api -   https://api.androidhive.info/contacts/  parse the data and show result in tableView. First create pod file instal...