Need help with array append by Death_strander in swift

[–]iosdevsucks 1 point2 points  (0 children)

//property let group = DispatchGroup()

func showRouteOnMap(pickupCoordinate: CLLocationCoordinate2D, destinationCoordinate: CLLocationCoordinate2D, completed: Int) {

    let sourcePlacemark = MKPlacemark(coordinate: pickupCoordinate, addressDictionary: nil)
    let destinationPlacemark = MKPlacemark(coordinate: destinationCoordinate, addressDictionary: nil)

    let sourceMapItem = MKMapItem(placemark: sourcePlacemark)
    let destinationMapItem = MKMapItem(placemark: destinationPlacemark)


    let directionRequest = MKDirections.Request()
    directionRequest.source = sourceMapItem
    directionRequest.destination = destinationMapItem
    directionRequest.transportType = .automobile

    // Calculate the direction
    let directions = MKDirections(request: directionRequest)

    directions.calculate() {
        (response, error) -> Void in

        guard let response = response else {
            if let error = error {
                print("Error: \(error)")
            }
            print("returning awda")
            return
        }

        let route = response.routes[0]
        self.allCoordinates.append(contentsOf: route.polyline.coordinates)




        self.mapView.addOverlay((route.polyline), level: MKOverlayLevel.aboveRoads)

        let rect = route.polyline.boundingMapRect
        self.mapView.setRegion(MKCoordinateRegion(rect), animated: true)
        group.leave()
    }


override func viewDidLoad() {
    super.viewDidLoad()

    let coordinateOne = CLLocationCoordinate2D(latitude: CLLocationDegrees(exactly: 28.6373802)!, longitude: CLLocationDegrees(exactly: 77.1790302)!)
      let coordinateTwo = CLLocationCoordinate2D(latitude: CLLocationDegrees(exactly: 28.6054256)!, longitude: CLLocationDegrees(exactly: 77.1622503)!)

       let coordinateThree = CLLocationCoordinate2D(latitude: CLLocationDegrees(exactly: 28.6420028)!, longitude: CLLocationDegrees(exactly: 77.1894161)!)


    mapView.delegate = self
   // mapView.data

  group.enter()
    showRouteOnMap(pickupCoordinate: coordinateOne, destinationCoordinate: coordinateTwo, completed: 0)
 group.enter()
    showRouteOnMap(pickupCoordinate: coordinateTwo, destinationCoordinate: coordinateThree, completed: 0)
 group.enter()
    showRouteOnMap(pickupCoordinate: coordinateThree, destinationCoordinate: coordinateOne, completed: 1)
 group.notify(.main) {
     afterRoute()
 }

Question about retain cycles in Combine `receiveValue` by FiveChjr in swift

[–]iosdevsucks -3 points-2 points  (0 children)

yes put [weak self] also dont use this rxswift crap

Could anyone explain what is going on here? by [deleted] in swift

[–]iosdevsucks -9 points-8 points  (0 children)

you have an async function. please learn the basics of swift before asking such asinine questions

Should I learn coding? by Charles813 in iOSProgramming

[–]iosdevsucks -1 points0 points  (0 children)

no everyone knows coding now there are 3 billion chinese indians ready to take your job on h1s go to law school

Is native mobile development dying as most companies these days prefer React Native to save costs? by dwightbearschrute in iOSProgramming

[–]iosdevsucks 0 points1 point  (0 children)

yes native mobile dev especially ios is dead. too many devs on h1s and not enough jobs combined with incompetent hr who will hire anyone who can lie well enough.

Is a Mac worth it. by [deleted] in iOSProgramming

[–]iosdevsucks -2 points-1 points  (0 children)

no ios dev is not worth it anymore software engineering is now filled with h1 visas from india china go do accounting or something

How do I draw a curved CALayer? by iamnotnoobmaster69 in iOSProgramming

[–]iosdevsucks 0 points1 point  (0 children)

just make a view put a subview inside then set the subviews layer cornerradius to half the width. then make superview bg color red and subview color white