{"id":57904,"date":"2022-12-30T03:01:24","date_gmt":"2022-12-29T17:01:24","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=57904"},"modified":"2022-12-30T07:39:27","modified_gmt":"2022-12-29T21:39:27","slug":"swift-playgrounds-on-macos-map-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/swift-playgrounds-on-macos-map-tutorial\/","title":{"rendered":"Swift Playgrounds on macOS Map Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Xcode\/swift_new_playground.gif\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Swift Playgrounds on macOS Map Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Xcode\/swift_new_playground.gif\" title=\"Swift Playgrounds on macOS Map Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Swift Playgrounds on macOS Map Tutorial<\/p><\/div>\n<p>Are you looking for &#8230;<\/p>\n<ul>\n<li>informal &#8230; but &#8230;<\/li>\n<li><a target=_blank title='Integrated Development Environment information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Integrated_development_environment'>IDE<\/a> based compiling &#8230;<\/li>\n<li>Swift &#8230; code based &#8230;<\/li>\n<li>macOS or iOS &#8230; suiting &#8230;<\/li>\n<\/ul>\n<p> &#8230; programming environment?   How about, if you are into the &#8220;where of&#8221; in life &#8230;<\/p>\n<ul>\n<li><a target=_blank title='Xcode IDE information from Apple' href='https:\/\/developer.apple.com\/technologies\/tools\/'>Xcode<\/a> on macOS &#8230;<\/li>\n<li>File -&gt; New -&gt; Playground&#8230;<\/li>\n<li>Map<\/li>\n<li>Next<\/li>\n<li>Create<\/li>\n<\/ul>\n<p>Now, by informal, we mean you don&#8217;t have to worry about Development or Deployment certificates, and all that jazz.  You just get to &#8220;play around&#8221;, make mistakes, take advice, and learn (more, on top of tutorials like <a title='Swift Playgrounds on iPad Primer Tutorial' href='#spppt'>Swift Playgrounds on iPad Primer Tutorial<\/a>) about Swift programming language, in the process!<\/p>\n<p>We had fun producing a macOS Swift playground desktop application that featured one local &#8220;Artwork&#8221; class (default) pin<font size=1>ning<\/font> map item, thanks to the great advice from <a target=_blank href='https:\/\/www.kodeco.com\/7738344-mapkit-tutorial-getting-started' title='MapKit Tutorial: Getting Started | Kodeco, the new raywenderlich.com'>MapKit Tutorial: Getting Started | Kodeco, the new raywenderlich.com<\/a> &#8230; thanks.  We ended up with &#8230;<\/p>\n<p><code><br \/>\n\/\/: A MapKit based Playground<br \/>\n<br \/>\nimport MapKit<br \/>\nimport PlaygroundSupport<br \/>\n<br \/>\nclass Artwork: NSObject, MKAnnotation {<br \/>\n  let title: String?<br \/>\n  let locationName: String?<br \/>\n  let discipline: String?<br \/>\n  let coordinate: CLLocationCoordinate2D<br \/>\n<br \/>\n  init(<br \/>\n    title: String?,<br \/>\n    locationName: String?,<br \/>\n    discipline: String?,<br \/>\n    coordinate: CLLocationCoordinate2D<br \/>\n  ) {<br \/>\n    self.title = title<br \/>\n    self.locationName = locationName<br \/>\n    self.discipline = discipline<br \/>\n    self.coordinate = coordinate<br \/>\n<br \/>\n    super.init()<br \/>\n  }<br \/>\n<br \/>\n  var subtitle: String? {<br \/>\n    return locationName<br \/>\n  }<br \/>\n}<br \/>\n<br \/>\nlet chatswoodCoordinates = CLLocationCoordinate2DMake(-33.8009948,151.1664372)<br \/>\n<br \/>\n\/\/ Now let's create a MKMapView<br \/>\nlet mapView = MKMapView(frame: CGRect(x:0, y:0, width:800, height:800))<br \/>\n<br \/>\n\/\/ Define a region for our map view<br \/>\nvar mapRegion = MKCoordinateRegion()<br \/>\n<br \/>\nlet mapRegionSpan = 0.001<br \/>\nmapRegion.center = chatswoodCoordinates<br \/>\nmapRegion.span.latitudeDelta = mapRegionSpan<br \/>\nmapRegion.span.longitudeDelta = mapRegionSpan<br \/>\n<br \/>\nmapView.setRegion(mapRegion, animated: true)<br \/>\n<br \/>\n\/\/ Create a map annotation<br \/>\nlet annotation = MKPointAnnotation()<br \/>\nannotation.coordinate = chatswoodCoordinates<br \/>\nannotation.title = \"Chatswood\"<br \/>\nannotation.subtitle = \"Greville\"<br \/>\n<br \/>\nmapView.addAnnotation(annotation)<br \/>\n<br \/>\n\/\/ Show artwork on map<br \/>\nlet artwork = Artwork(<br \/>\n  title: \"The Cheesetree\",<br \/>\n  locationName: \"Santa Clause Lane\",<br \/>\n  discipline: \"Nature, like\",<br \/>\n  coordinate: CLLocationCoordinate2D(latitude: -33.8010376, longitude: 151.1663819))<br \/>\n<br \/>\nmapView.addAnnotation(artwork)<br \/>\n<br \/>\n\/\/ Add the created mapView to our Playground Live View<br \/>\nPlaygroundPage.current.liveView = mapView<br \/>\n<\/code><\/p>\n<p> &#8230; in <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Xcode\/MyPlayground.swift_GETME\" title=\"MyPlayground.swift\">MyPlayground.swift<\/a> Swift source code macOS Swift desktop application code.<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/new-swift-playgrounds-on-ipad-primer-tutorial\/'>Swift Playgrounds on iPad Primer Tutorial<\/a>.<\/p-->\n<hr>\n<p id='spppt'>Previous relevant <a target=_blank title='Swift Playgrounds on iPad Primer Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/swift-playgrounds-on-ipad-primer-tutorial\/'>Swift Playgrounds on iPad Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/iPad\/ipad_ide.pdf\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Swift Playgrounds on iPad Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Mac\/iPad\/ipad_ide.jpg\" title=\"Swift Playgrounds on iPad Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Swift Playgrounds on iPad Primer Tutorial<\/p><\/div>\n<p>Generally speaking around here, we tend to think you need at least a laptop (eg. MacBook Pro) or desktop computer PC (macOS or Windows) or Linux operating system arrangement, to (computer) program <font size=1>(in other words, the iOS operating system is a missing part of the equation here)<\/font>.  That has led us to <a target=_blank title='?' href='https:\/\/adventuresinjournalism.substack.com\/p\/check-yourself'><i>ass<\/i>u<b>me<\/b><\/a> more than we know, though looking into this topic via our <a target=_blank title='Google' href='https:\/\/google.com'>Google<\/a> search of &#8230;<\/p>\n<p><code><br \/>\n<a target=_blank title='ide for ipad' href='https:\/\/www.google.com\/search?q=ide+for+ipad&#038;rlz=1C5CHFA_enAU832AU832&#038;oq=ide+for+ipad&#038;aqs=chrome..69i57j0l3j0i395j0i22i30i395l5.3429j1j4&#038;sourceid=chrome&#038;ie=UTF-8'>ide for ipad<\/a><br \/>\n<\/code><\/p>\n<p> &#8230; had us first looking into Python via &#8220;pythonista&#8221;, but the $14.99 price tag was far too much for us to absorb so early in the morning, and a warning that exclusive &#8220;above the fold&#8221; reading can have you suffer from (FOMO) &#8220;fear of missing out&#8221; syndrome.  Reading, then, below the fold, soon turned up the <a target=_blank title='Xcode information from Apple' href='https:\/\/developer.apple.com\/xcode\/'>Xcode<\/a> IDE (we have on macOS, here, and appears &#8220;above the fold&#8221; regarding blurb actions above) programming language of choice, Swift, with its <a target=_blank title='Apple' href='https:\/\/apple.com'>Apple<\/a> iPad place &#8230;<\/p>\n<p><code><br \/>\n<a target=_blank title='Swift Playgrounds' href='https:\/\/www.apple.com\/au\/swift\/playgrounds\/'>Swift Playgrounds<\/a><br \/>\n<\/code><\/p>\n<p> &#8230; as a great resource into programming and &#8220;robotics feeling&#8221; coding leading to &#8220;programming action&#8221;!   And the presentation may well suit young&#8217;uns getting into programming early, if that&#8217;s why you are reading this blog posting.  As Swift Playgrounds starts out intimating, to &#8220;follow a recipe&#8221; and perform &#8220;steps in order&#8221; is likely to lead to the happiest programming and coding experience <font size=1>(to put it mildly &#8230; or &#8230; <\/font><font size=6>just follow orders<\/font><font size=4> &#8230; initially<\/font><font size=2> &#8230; to put it more bluntly<\/font><font size=1>)<\/font>.<\/p>\n<p>Curiosity is the big key here.  Start this way, and invariably if it interests, it interests, and could lead to many other avenues of knowledge, and it involving the Swift computer language, that could be a lead in to iOS mobile app development via Xcode and (paying, or not) careers in Information Technology?!<\/p>\n<p>Or perhaps you are on an iPad and wish to fork out the $14.99 and get into Python, then that would be <a target=_blank title='?' href='https:\/\/www.youtube.com\/watch?v=krD4hdGvGHM'>interesting<\/a> too, we have no doubt.  Either way, see how we R&#038;D<font size=1>&#8216;ed<\/font> this topic, on an iPad, with today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/iPad\/ipad_ide.pdf\" title=\"Click picture\">PDF presentation<\/a> <font size=1>(dare we say)<\/font> <font size=4>following orders<\/font>.<\/p>\n<p>We&#8217;ve also heard, but have not researched this, that Apple is making changes with iPad products into the future, to improve their programming capacities.  Stay tuned, <a onclick=\"alert('We shall still be striking an assume macOS pose!  For now.');\" style=\"cursor:pointer;text-decoration:underline;\">with Apple<\/a>, on that.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d51031' onclick='var dv=document.getElementById(\"d51031\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/ipad\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d51031' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d57904' onclick='var dv=document.getElementById(\"d57904\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/swift\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d57904' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Are you looking for &#8230; informal &#8230; but &#8230; IDE based compiling &#8230; Swift &#8230; code based &#8230; macOS or iOS &#8230; suiting &#8230; &#8230; programming environment? How about, if you are into the &#8220;where of&#8221; in life &#8230; Xcode &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/swift-playgrounds-on-macos-map-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,29,33,37,40],"tags":[91,96,170,4191,241,319,1726,585,684,719,2178,745,4190,997,1227,1319,2580,1473],"class_list":["post-57904","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-software","category-tutorials","category-xcode","tag-apple","tag-application","tag-build","tag-compilation","tag-compile","tag-desktop","tag-google-map","tag-ide","tag-latitude","tag-longitude","tag-macos","tag-map","tag-playground","tag-programming","tag-swift","tag-tutorial","tag-where","tag-xcode"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/57904"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=57904"}],"version-history":[{"count":7,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/57904\/revisions"}],"predecessor-version":[{"id":57915,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/57904\/revisions\/57915"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=57904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=57904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=57904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}