2 Replies
      Latest reply on Nov 23, 2018 12:22 PM by Claude31
      savoca Level 1 Level 1 (0 points)

        Hello. I have bought a brand new Macbook and installed the latest version of macOS, Xcode and Xcode development tools. I assume if I am going to be learning how to write code with Xcode, this would be an ideal setup. I open Xcode and click on the first option 'Get started with a playground.' Since I have a Macbook, I then click on 'macOS' and for fun, I click on the 'Map' option instead of 'Blank.' I click on the location of 'MyPlayground' and an editor window shows up with some code that looks like Swift:


        //: A MapKit based Playground
        import MapKit
        import PlaygroundSupport
        let appleParkWayCoordinates = CLLocationCoordinate2DMake(37.334922, -122.009033)
        // Now let's create a MKMapView
        let mapView = MKMapView(frame: CGRect(x:0, y:0, width:800, height:800))
        // Define a region for our map view
        var mapRegion = MKCoordinateRegion()
        let mapRegionSpan = 0.02
        mapRegion.center = appleParkWayCoordinates
        mapRegion.span.latitudeDelta = mapRegionSpan
        mapRegion.span.longitudeDelta = mapRegionSpan
        mapView.setRegion(mapRegion, animated: true)
        // Create a map annotation
        let annotation = MKPointAnnotation()
        annotation.coordinate = appleParkWayCoordinates
        annotation.title = "Apple Inc."
        annotation.subtitle = "One Apple Park Way, Cupertino, California."
        // Add the created mapView to our Playground Live View
        PlaygroundPage.current.liveView = mapView


        After I see this code, nothing happens. Xcode options to run and debug the code are greyed out. What is the purpose of this code? Is a 'Playground' just a project containing text files for note taking? Is there a secret cheat code?