As mentioned in the main title we can see that what this is all about and what will we achieve by the end of this tutorial for the Swift Ios in how can one get the country phone code without using any library

Well let,s move ahead and without taking…

Here is my workaround to create a collage view like WhatsApp using Stack View in Swift IOS.


// ViewController.swift


// Created by Apple on 17.05.21.


import UIKit

class ViewController: UIViewController {

var logoImage: [UIImage] = [

UIImage(named: “first.jpeg”)!,

UIImage(named: “second.jpeg”)!,

UIImage(named: “third.jpeg”)!,

UIImage(named: “fourth.png”)!


override func

func UPLOD()


//Parameter HERE

let parameters = [

“id”: “1221”,

“docsFor” : “wqww”


//Header HERE

let headers = [


“Content-type”: “multipart/form-data”,

“Content-Disposition” : “form-data”


let image = UIImage.init(named: “imagename”)

let imgData = UIImageJPEGRepresentation(image!, 0.7)!

Alamofire.upload(multipartFormData: { multipartFormData in

//Parameter for Upload files

multipartFormData.append(imgData, withName: “file”,fileName: “imagename.png” , mimeType: “image/png”)

for (key, value) in parameters


multipartFormData.append( String.Encoding.utf8)!, withName: key)


}, usingThreshold:UInt64.init(),

to: “http:API-for-url-her”, //URL Here

method: .post,

headers: headers, //pass header dictionary here

encodingCompletion: { (result) in

switch result {

case .success(let upload, _, _):

print(“the status code is :”)

upload.uploadProgress(closure: { (progress) in



upload.responseJSON { response in

print(“the resopnse code is : \(response.response?.statusCode)”)

print(“the response is : \(response)”)



case .failure(let encodingError):

print(“the error is : \(encodingError.localizedDescription)”)





Usman Abid

✅ Hi, I’m experienced iOS/Swift/Android/java/React Native App Developer from Pakistan. I am focusing Swift (iOS) with UIKit and android with java/kt and RN Dev.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store