Posts

Post not yet marked as solved
2 Replies
416 Views
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.
Posted
by davidd.
Last updated
.
Post not yet marked as solved
0 Replies
461 Views
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.
Posted
by davidd.
Last updated
.
Post not yet marked as solved
0 Replies
517 Views
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.
Posted
by davidd.
Last updated
.
Post not yet marked as solved
9 Replies
2.1k Views
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
Posted
by davidd.
Last updated
.
Post not yet marked as solved
6 Replies
4.1k Views
I'm trying to use Apple's CoreDataCloudkitDemo app. I've only changed the app settings per the README document. On running the demo, I'm getting the error: "CloudKit integration requires does not support ordered relationships."The console log shows:Fatal error: ###persistentContainer: Failed to load persistent stores:Error Domain=NSCocoaErrorDomain Code=134060 "A Core Data error occurred." UserInfo={NSLocalizedFailureReason=CloudKit integration requires does not support ordered relationships. The following relationships are marked ordered: Post: attachmentsDoes anyone have a workaround, or preferably, a fix? Or did I do something wrong?Thanks
Posted
by davidd.
Last updated
.
Post not yet marked as solved
1 Replies
1.4k Views
I'm trying to add a map to a watchOS 5 app. Currently, I'm running only on the Simulator.I can see my pin annotation, but not the map itself. Any help would be appreciated.Code:@IBOutlet weak var stationMap: WKInterfaceMap! var locationManager: CLLocationManager! var location = CLLocationCoordinate2D() var region = MKCoordinateRegion() var lat: Double! var lon: Double!override func willActivate() { // This method is called when watch view controller is about to be visible to user super.willActivate() location.latitude = (CLLocationDegrees(lat)) location.longitude = (CLLocationDegrees(lon)) //NSLog(@"Map: mapDetailArray: %@", self.mapDetailArray); locationManager = CLLocationManager() let spanX: Float = 0.005 let spanY: Float = 0.005 region.center = location region.span.latitudeDelta = CLLocationDegrees(spanX) region.span.longitudeDelta = CLLocationDegrees(spanY) stationMap.setRegion(region) stationMap.addAnnotation(location, with: .red) }
Posted
by davidd.
Last updated
.
Post marked as solved
6 Replies
1.6k Views
Hi, I'm trying to use ADF instead of SO.I have the following code:for i in 0.. currentStation = [trainArray[i]] print("currentStation: ", currentStation[0] ) print ("currentStation type", type(of: currentStation)) }This results in the following console output:currentStation: [AnyHashable("Car"): AnyHashable("8"), AnyHashable("Group"): AnyHashable("2"), AnyHashable("DestinationCode"): AnyHashable("F11"), AnyHashable("Min"): AnyHashable("BRD"), AnyHashable("Destination"): AnyHashable("Brnch Av"), AnyHashable("Line"): AnyHashable("GR"), AnyHashable("DestinationName"): AnyHashable("Branch Ave"), AnyHashable("LocationName"): AnyHashable("Archives-Navy Memorial-Penn Quarter"), AnyHashable("LocationCode"): AnyHashable("F02")] currentStation type ArrayI'm confused how use the values within currentStation? Any help will be appreciated.
Posted
by davidd.
Last updated
.