IOS – Main Thread Checker: UI API called on a background thread: -[UIApplication delegate] PID: 902, TID: 13120, Thread name: (none), Queue name: NSOperationQueue 0x604000037a20 (QOS: UNSPECIFIED), QoS: 0 Backtrace:

Solution : use DispatchQueue.main.async { // Correct }     Updating UI from a Completion Handler Long-running tasks such as networking are often executed in the background, and provide a completion handler to signal completion. Attempting to read or update the UI from a completion handler may cause problems. let task = URLSession.shared.dataTask(with: url) { […]

Swift 3 / 4 get current location with location manager .

Step – 1 :  First define LocationManager . And Current location of CLLocaion .   var manager = CLLocationManager() var currentLocation: CLLocation! Step 2 : In ViewDidController get Current location with location manager . That’s it .   manager.requestWhenInUseAuthorization()                  if (CLLocationManager.authorizationStatus() == CLAuthorizationStatus.authorizedWhenInUse ||       […]

Swift 3 /4 take photo from camera or gallery and show it .

Step One : First create a project and take imageView and a button to capture image . Connect it to ViewController . Step Two : Copy this code and run . hope it will be done . 😀    class ImageCapture: UIViewController , UIImagePickerControllerDelegate,UIPopoverControllerDelegate,UINavigationControllerDelegate{      @IBOutlet var imageViewWeight: UIImageView!      var imagePicker:UIImagePickerController?=UIImagePickerController() override func viewDidLoad() { […]

Swift Tutorial Series In Bangla : Collection Type – Array

Source Code import UIKit var integerTypeArray = [Int]() integerTypeArray.append(3) integerTypeArray.append(5) var stringTypeArray = [String]() stringTypeArray.append(“ios”) var threeWillbeTenTimesArray = Array(repeatElement(“Three”, count: 10)) var fiveWillbeTenTimesArray = Array(repeatElement(“Five”, count: 10)) var addThreeAndFiveArray = threeWillbeTenTimesArray + fiveWillbeTenTimesArray var literalTypeArray : [String] = [“swift”,”version”,”three”] literalTypeArray[0] for eachElementValue in literalTypeArray { print(eachElementValue) } var countofArray = literalTypeArray.count var retriveLastElement = literalTypeArray[literalTypeArray.count-1] […]