Post

Replies

Boosts

Views

Activity

Timer doesn't quit
I have a timer that runs ok. However, when I try to stop the timer, neither function is executed. The code is as follows: ` func viewWillDisappear(animated: Bool) { super.viewWillDisappear(animated) print(#function) menuTimer = nil menuTimer?.invalidate() } override func viewDidDisappear(_ animated: Bool) { print(#function) super.viewDidDisappear(animated) menuTimer = nil menuTimer?.invalidate() } Is this a known issue or am i doing something wrong.
3
0
587
Jul ’23
More help with CloudKit please
Hi, I'm trying to add CloudKit to my app. I've added a provisioning profile to the app, after enabling the required entitlements. When I run the app, I get the following message: Error Domain=SyncedDefaults Code=101010 "Tried to access unknown store xxxxxxxxx.com.bohtech.xxxxxxxx" UserInfo={NSLocalizedDescription=Tried to access unknown store I can see the container through the Apple website. I can see the Private Zone. I cannot get further than that. I've tried rebuilding the entitlement file, restarting my computer. Disabling and re-enabling the container through Xcode. Can someone out there point me to any help? Thanks in advance.
0
0
561
Nov ’22
watchOS - map shows for an instant, then replaced with blue screen
I have a watchOS app that shows a map with the device's current location. This works as expected on a simulator. On a device in TestFlight, the map shows for an instant, but then the map area turns blue. When I zoom in and out, again, the correct map shows for an instant, but then the screen turns blue. I have a couple of images to illustrate the issue: I'm attaching the mapping code below: super.awake(withContext: context) if CLLocationManager.locationServicesEnabled() { locationManager.requestAlwaysAuthorization() locationManager.requestWhenInUseAuthorization() locationManager.delegate = self locationManager.desiredAccuracy = kCLLocationAccuracyBest locationManager.distanceFilter = kCLDistanceFilterNone locationManager.startUpdatingLocation() } else { print("Problem with permissions") return } let span = MKCoordinateSpan( latitudeDelta: 0.005, longitudeDelta: 0.005 ) #if targetEnvironment(simulator) let location = CLLocationCoordinate2D( latitude: simulatorLatitude, longitude: simulatorLongitude ) let region = MKCoordinateRegion(center: location, span: span) mapView.setRegion(region) mapView.addAnnotation(location, withImageNamed: "mapPinRed", centerOffset: CGPoint(x: 0, y: 0)) #else locationManager.requestLocation() #endif } override func willActivate() { // This method is called when watch view controller is about to be visible to user } override func didDeactivate() { // This method is called when watch view controller is no longer visible } func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { print(#function, "Status: ", status.rawValue) if status.rawValue == 0 { locationManager.requestAlwaysAuthorization() locationManager.requestWhenInUseAuthorization() locationManager.requestLocation() } } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { let currentLocation = locations[0] let lat = currentLocation.coordinate.latitude let long = currentLocation.coordinate.longitude self.mapLocation = CLLocationCoordinate2DMake(lat, long) //let span = MKCoordinateSpan.init(latitudeDelta: 0.1, longitudeDelta: 0.1) let region = MKCoordinateRegion.init() self.mapView.setRegion(region) self.mapView.addAnnotation(self.mapLocation!, with: .red) } func centerMapOnLocation(location: CLLocation) { #if targetEnvironment(simulator) let region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: simulatorLatitude, longitude: simulatorLongitude), span: MKCoordinateSpan(latitudeDelta: CLLocationDegrees(zoomValue), longitudeDelta: CLLocationDegrees(zoomValue))) DispatchQueue.main.async { self.mapView.setRegion(region) } #else let region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude), span: MKCoordinateSpan(latitudeDelta: CLLocationDegrees(zoomValue), longitudeDelta: CLLocationDegrees(zoomValue))) DispatchQueue.main.async { [self] in self.mapView.setRegion(region) self.mapView.addAnnotation(location.coordinate, withImageNamed: "mapPinRed", centerOffset: CGPoint(x: 0, y: 0)) } #endif } My permissions are set in Watch.extension info.plist as follows: Privacy - Location Always Usage Description Privacy - Location Always and When In Use Usage Description Privacy - Location Usage Description I  would appreciate any help.
0
0
617
Jan ’22
Converting a number to different base(s)
Hi. I'm trying to convert numbers between decimal, binary, octal and hex. I've made a little Playground to explore. Code is this: let myNumber = "12345" let myBinary = (UInt8(myNumber, radix: 2) != nil) print(myBinary) let myOctal = Int(myNumber, radix: 8) print(myOctal!) let myHex = Int(myNumber, radix: 16) print(myHex!) let h2 = "27" let d4 = Int(h2, radix: 2)! print(d4) I seem to be getting garbage responses, including this crash: false 5349 74565 Fatal error: Unexpectedly found nil while unwrapping an Optional value: file __lldb_expr_60/Playground4.playground, line 16 Playground execution failed: error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation. People can play with this code. Please let me know or what to do. Many thanks
9
0
2.5k
Nov ’20