<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kiran Jadhav on Medium]]></title>
        <description><![CDATA[Stories by Kiran Jadhav on Medium]]></description>
        <link>https://medium.com/@kiransjadhav111?source=rss-3de7a30b6bae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*XSb-7StUAMPMfqZ6S42iMw.png</url>
            <title>Stories by Kiran Jadhav on Medium</title>
            <link>https://medium.com/@kiransjadhav111?source=rss-3de7a30b6bae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 01:24:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kiransjadhav111/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[CoreLocation & Map Kit— Get The User’s Current Location & Set A Pin In Swift]]></title>
            <link>https://medium.com/@kiransjadhav111/corelocation-map-kit-get-the-users-current-location-set-a-pin-in-swift-edb12f9166b2?source=rss-3de7a30b6bae------2</link>
            <guid isPermaLink="false">https://medium.com/p/edb12f9166b2</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[core-location]]></category>
            <category><![CDATA[mapkit]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[mapview]]></category>
            <dc:creator><![CDATA[Kiran Jadhav]]></dc:creator>
            <pubDate>Tue, 19 Nov 2019 11:08:27 GMT</pubDate>
            <atom:updated>2019-11-19T11:08:27.223Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R7gcAM7P9Wnl_9qQcpq0dg.jpeg" /></figure><blockquote><strong>1. Get the user’s current location</strong></blockquote><p>In this blog, I am going to share with you how to get the user’s current location on a MapView. For getting a user current location, we will use the <strong><em>CoreLocation</em></strong> framework for location updates and <strong><em>MapKit</em></strong> framework in order to show user current position on the map(using Xcode Storyboard).</p><p>To begin with let’s open Xcode and create a new project with a Single View App.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qx5ApKvgIgY8ykwh0zfqXA.png" /></figure><p>Open “<strong>Main.storyboard</strong>” and on your ViewController’s view drag “Map Kit View” i.e. <strong>MKMapView</strong>. Select a map view and place map view on your view of a view controller.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*421X2sE37WxGaUNmtrNHnQ.png" /></figure><p>Open “<strong>ViewController.swift</strong>” and create IBOutlet for “<strong>MKMapView</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gtMbsHgEn_Qq2kcBrKz4qg.png" /></figure><p>To get a user’s current location, you’ll first need to import <strong>MapKit</strong> and <strong>CoreLocation</strong> in the top of your view controller.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*spPTtOrWFL2_9UQrvG5vgA.png" /></figure><p><strong><em>Update Info.plist file :</em></strong></p><p>Your app to be able to request the user’s current location, you will need to open <strong>Info.plist</strong> file and add the following two permission.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*uLvm7xNwX-026cCmTNrT0Q.png" /></figure><p>Below is the complete source code in swift, that we detect user current location.</p><pre>import UIKit<br>import MapKit<br>import CoreLocation<br><br>class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {</pre><pre><br><em>    //MARK:- Variable Declarations<br></em><br>    @IBOutlet weak var mMapView: MKMapView!<br>    var locationManager:CLLocationManager!<br>    var currentLocationStr = &quot;Current location&quot;</pre><pre><br><em>    //MARK:- ViewController LifeCycle Methods<br></em><br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>    }<br><br>    override func viewDidAppear(_ animated: Bool) {<br>        determineCurrentLocation()<br>    }</pre><pre><br><em>    //MARK:- CLLocationManagerDelegate Methods<br></em><br>    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {<br>        let mUserLocation:CLLocation = locations[0] as CLLocation<br><br>        let center = CLLocationCoordinate2D(latitude: mUserLocation.coordinate.latitude, longitude: mUserLocation.coordinate.longitude)<br>        let mRegion = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))<br><br>        mMapView.setRegion(mRegion, animated: true)<br>    }<br></pre><pre>func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {<br>        print(&quot;Error - locationManager: \(error.localizedDescription)&quot;)<br>    }<br></pre><pre><em>//MARK:- Intance Methods</em><strong><br></strong><br>func determineCurrentLocation() {<br>    locationManager = CLLocationManager()<br>    locationManager.delegate = self<br>    locationManager.desiredAccuracy = kCLLocationAccuracyBest<br>    locationManager.requestAlwaysAuthorization()<br><br>    if CLLocationManager.locationServicesEnabled() {<br>        locationManager.startUpdatingLocation()<br>    }<br>}</pre><blockquote><strong>2. Set a pin at current location</strong></blockquote><p>We will also learn how to drop a Pin(<strong>MKPointAnnotation</strong>) at the user’s current location and set MKPointAnnotation title.</p><pre>func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {</pre><pre>    let mUserLocation:CLLocation = locations[0] as CLLocation<br>    let center = CLLocationCoordinate2D(latitude: mUserLocation.coordinate.latitude, longitude: mUserLocation.coordinate.longitude)<br>    let mRegion = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))</pre><pre>    mMapView.setRegion(mRegion, animated: true)<br><br><em>    // Get user&#39;s Current Location and Drop a pin</em></pre><pre>let mkAnnotation: MKPointAnnotation = MKPointAnnotation()<br>    mkAnnotation.coordinate = CLLocationCoordinate2DMake(mUserLocation.coordinate.latitude, mUserLocation.coordinate.longitude)<br>    mkAnnotation.title = self.setUsersClosestLocation(mLattitude: mUserLocation.coordinate.latitude, mLongitude: mUserLocation.coordinate.longitude)<br>    mMapView.addAnnotation(mkAnnotation)</pre><pre>}</pre><pre><em>//MARK:- Intance Methods<br></em><br>func setUsersClosestLocation(mLattitude: CLLocationDegrees, mLongitude: CLLocationDegrees) -&gt; String {<br>    let geoCoder = CLGeocoder()<br>    let location = CLLocation(latitude: mLattitude, longitude: mLongitude)<br><br>    geoCoder.reverseGeocodeLocation(location) {<br>        (placemarks, error) -&gt; Void in<br><br>        if let mPlacemark = placemarks{<br>            if let dict = mPlacemark[0].addressDictionary as? [String: Any]{<br>                if let Name = dict[&quot;Name&quot;] as? String{<br>                    if let City = dict[&quot;City&quot;] as? String{<br>                        self.currentLocationStr = Name + &quot;, &quot; + City<br>                    }<br>                }<br>            }<br>        }<br>    }<br>    return currentLocationStr<br>}</pre><p>Changing locations on the simulator is a better way to test features, without physically having to move to different locations. To change the location on your iOS simulator go to Debug &gt; Location &gt; Custom Location</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*OWzYrKB-gfmt8hWI5AhCIw.png" /></figure><p>Here you will be able to set the longitude and latitude to any location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*FGkRC5FnGuuUTAA1gMicHA.png" /></figure><h3>It`s a wrap</h3><p>I hope the above tutorial will help to clear the concepts of <strong><em>CoreLocation &amp; MapKit</em></strong>. If the article has helped you and you want me to continue writing similar articles, you are welcome to support me with a small donation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edb12f9166b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Use WKWebView?
Migrating UIWebView to WKWebView With Swift]]></title>
            <link>https://medium.com/@kiransjadhav111/how-to-use-wkwebview-migrating-uiwebview-to-wkwebview-with-swift-30506885d916?source=rss-3de7a30b6bae------2</link>
            <guid isPermaLink="false">https://medium.com/p/30506885d916</guid>
            <category><![CDATA[webkit]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[webview]]></category>
            <category><![CDATA[wkwebview]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Kiran Jadhav]]></dc:creator>
            <pubDate>Tue, 15 Oct 2019 08:02:15 GMT</pubDate>
            <atom:updated>2019-10-15T08:02:15.565Z</atom:updated>
            <content:encoded><![CDATA[<h3>How To Use WKWebView?<br>Migrating UIWebView to WKWebView In Swift</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*wIA0eqaR0dVRcVQh1O3J-Q.png" /><figcaption>It’s part of the <strong>WebKit</strong> framework rather than the <strong>UIKit</strong> framework</figcaption></figure><p>In <strong>iOS 12</strong>, WIWebView will be removed from the iOS SDKs and replaced with WKWebView. If your app uses, you’ll probably have to upgrade it to use WKWebView.</p><p><strong>WKWebView</strong> display interactive web content in your app. Ideal for displaying complete web pages or HTML markup. It’s like having a small web browser right in your mobile application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*49ZRpuGoEGPjuAMmTdj_Bw.png" /><figcaption>The WKWebView a component is a replacement for UIWebView.</figcaption></figure><blockquote><strong>1. Loading A Web Page :</strong></blockquote><p>Adding a <strong>WKWebView</strong> to your app is as simple, Here’s how:</p><p>To begin with let’s open <strong>Xcode</strong> and create a new project with a <strong>Single View App.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qx5ApKvgIgY8ykwh0zfqXA.png" /></figure><p>Open “<strong>Main.storyboard</strong>” and on your ViewController’s view drag “<strong>WebKit</strong> <strong>View</strong>” i.e. <strong>WKWebView. </strong>Select a WKWebView and place on your view of a view controller.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cAhwBZyaf7U0yByPFMjb0Q.png" /></figure><p>Open “<strong>ViewController.swift</strong>” and create IBOutlet for “<strong>WKWebView</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NSUe7wQcEQogBU_YgU8LpQ.png" /></figure><p>The <strong>WKWebView</strong> class can be used to display web content in your iOS app, like an in-app browser. It’s part of the <strong>WebKit</strong> framework rather than the <strong>UIKit</strong> framework, but we can <strong>import</strong> it by adding this line to the top of <strong>ViewController.swift</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*bcKxZUEz-9wDk15gUO_VrA.png" /></figure><p>Assuming you’re using a WKWebView in your view controller, you would add the above code to the <strong>viewDidLoad()</strong> function is given below;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4XP-nTmhkQ_ABXr9YHUhjQ.png" /></figure><p>When you run your app, you’ll see that the web page shows up! And it’s completely interactive, so you can navigate the web page like an ordinary browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*1kqYkZ_IY5pp8gheOO6ySw.png" /><figcaption>When you run app it will look like the same.</figcaption></figure><blockquote><strong>2. How to Respond With WKWebView Events With WKNavigationDelegate :</strong></blockquote><p>However, you can interact with the web view using a number of properties, objects, and delegate protocols. A <strong>WKWebView</strong> web view has two main delegate protocols and properties:</p><p>navigationDelegate of type WKNavigationDelegate,which responds to navigation events and uiDelegateof type WKUIDelegate which responds to user interaction events.</p><p>First, let’s adopt the protocol and set the webView delegate. Here’s how:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*89x8yZrF9ZvyXcV0Me7N5w.png" /></figure><p>Set the <strong>navigationDelegate</strong> property of webView to self, before loading the web request, like <strong>mWKWebView.navigationDelegate = self</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*PQVYp_j3S6GmvNDMci8_GA.png" /></figure><p>Below is the complete source code in swift ;</p><pre>import UIKit<br>import WebKit<br><br>class ViewController: UIViewController, WKNavigationDelegate {<br><br>    //MARK:- Variable Declarations<br><br>    @IBOutlet weak var mWKWebView: WKWebView!<br><br>    //MARK:- ViewController LifeCycle Methods<br><br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        let request = URLRequest(url: URL(string: &quot;https://developer.apple.com/documentation/webkit/wkwebview&quot;)!)<br>        mWKWebView.navigationDelegate = self<br>        mWKWebView.load(request)<br>    }<br><br>    //MARK:- WKNavigationDelegate Methods<br><br>    //Equivalent of shouldStartLoadWithRequest:<br>    func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -&gt; Void) {<br>        var action: WKNavigationActionPolicy?<br><br>        defer {<br>            decisionHandler(action ?? .allow)<br>        }<br><br>        guard let url = navigationAction.request.url else { return }<br>        print(&quot;decidePolicyFor - url: \(url)&quot;)<br><br>        //Uncomment below code if you want to open URL in safari<br>        /*<br>        if navigationAction.navigationType == .linkActivated, url.absoluteString.hasPrefix(&quot;https://developer.apple.com/&quot;) {<br>            action = .cancel  // Stop in WebView<br>            UIApplication.shared.open(url)<br>        }<br>        */<br>    }<br><br>    //Equivalent of webViewDidStartLoad:<br>    func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {<br>        print(&quot;didStartProvisionalNavigation - webView.url: \(String(describing: webView.url?.description))&quot;)<br>    }<br><br>    //Equivalent of didFailLoadWithError:<br>    func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {<br>        let nserror = error as NSError<br>        if nserror.code != NSURLErrorCancelled {<br>            webView.loadHTMLString(&quot;Page Not Found&quot;, baseURL: URL(string: &quot;https://developer.apple.com/&quot;))<br>        }<br>    }<br><br>    //Equivalent of webViewDidFinishLoad:<br>    func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {<br>        print(&quot;didFinish - webView.url: \(String(describing: webView.url?.description))&quot;)<br>    }<br><br>}</pre><h3>It`s a wrap</h3><p>I hope the above tutorial will help to clear the concepts of <strong><em>WKWebView</em></strong>. If the article has helped you and you want me to continue writing similar articles, you are welcome to support me with a small donation.</p><p>Thanks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30506885d916" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>