Post

Replies

Boosts

Views

Activity

Architecting for subscriptions - example code error: SyntaxError: Unexpected token s in JSON at position 0
I followed the instructions in: Determining Service Entitlement on the Server https://developer.apple.com/documentation/storekit/in-app_purchase/subscriptions_and_offers/determining_service_entitlement_on_the_server Running the following: curl -XPOST -H "Content-type: application/json" -d 'simulateExamples/flatJsonExample.json' 'localhost:3000/simulate' got the error: node ./bin/www POST /simulate 400 8.436 ms - 1276 SyntaxError: Unexpected token s in JSON at position 0 I validated flatJsonExample.json with lint and it was OK.
1
0
933
Jun ’20
How to use SwiftUI to display a map and handle touch on the map?
I want to use SwiftUI to display a map and handle touch on the map. Here is my code so far. I have a problem integrating GestureRecognizer in Coordinator specifically accessing self.mapView inside it.Also adding addGestureRecognizer. How to do that?=======================================//// ContentView.swiftimport SwiftUIimport Gomobiletidbstruct ContentView: View { var body: some View { VStack { MapView() .edgesIgnoringSafeArea(.vertical) Text("Turtle Rock") .font(.title) .padding(.leading, 15) .padding(.top, 5) .textFieldStyle(RoundedBorderTextFieldStyle()) VStack { HStack { Text("Joshua Tree National Park") .font(.subheadline) Spacer() Text("California") .font(.subheadline) } .padding() } }}=======================================//// MapView.swiftimport SwiftUIimport MapKitstruct MapView: UIViewRepresentable { func makeCoordinator() -> Coordinator { Coordinator(self) } final class Coordinator: NSObject, MKMapViewDelegate { var control: MapView init(_ control: MapView) { self.control = control longPressGestureRecognizer = UILongPressGestureRecognizer(target: self.control, action: #selector(Coordinator.mapViewLongTapRecognizer(gestureRecognizer:))) control.addGestureRecognizer(longPressGestureRecognizer) } @objc func mapViewLongTapRecognizer( gestureRecognizer: UILongPressGestureRecognizer) { if (gestureRecognizer == longPressGestureRecognizer){ if (gestureRecognizer.numberOfTouchesRequired == 1){ if gestureRecognizer.state == UIGestureRecognizer.State.began { let touchPoint: CGPoint = gestureRecognizer.location(in: self.mapView) } } } } // MARK: - MKMapViewDelegate func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer { let renderer = MKOverlayPathRenderer() return renderer } func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { return annotation as? MKAnnotationView } } func makeUIView(context: Context) -> MKMapView { let mapView = MKMapView(frame: .zero) mapView.delegate = context.coordinator mapView.mapType = .hybrid mapView.showsCompass = true mapView.showsUserLocation = true mapView.showsBuildings = true return mapView } func updateUIView(_ mapView: MKMapView, context: Context) { longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(Coordinator.mapViewLongTapRecognizer(gestureRecognizer:))) mapView.addGestureRecognizer(longPressGestureRecognizer) let span = MKCoordinateSpan(latitudeDelta: 2.0, longitudeDelta: 2.0) let region = MKCoordinateRegion(center: currentLocation.coordinate, span: span) mapView.setRegion(region, animated: true) }}struct MapView_Preview: PreviewProvider { static var previews: some View { MapView() }}=======================================
1
0
3.5k
Aug ’19