Posts

Post not yet marked as solved
0 Replies
218 Views
Is there a programmatic means of getting an iPhone camera lens' magnification level? I'm referring to the .5x, 1x and 2.x/2.5x/3.x values for the ultra wide, wide and telephoto lenses available on iPhones of the last few years. I tried accessing the AVCaptureDevice videoZoomFactor property, but that returns the same value for both of my iPhone's cameras.
Posted
by dsbirch.
Last updated
.
Post not yet marked as solved
0 Replies
784 Views
I have been able to reproduce a problem with running a SwiftUI iOS app project converted in Xcode 13 beta for use in Xcode 12. Doing so is consistently resulting in the main view's top and bottom being cut off and centered within a black background (I believe this is referred to as "letterboxing"). Here are the steps to follow: Use xcode-select to set your environment for the Xcode 13 beta and launch it. Create a new SwiftUI app In its ContentView file, add some content Run the project in the iOS Simulator Select the project in the Project navigator and in the File Inspector, change the Project Format dropdown menu to Xcode 11.4-compatible or Xcode 12-compatible. Quit the Xcode beta and the Simulator. Use xcode-select to set your environment for Xcode 12.5 and launch it. Open the project you created in Xcode 13 beta and run it in the iOS Simulator. Your simulator screen should look something like the screenshot below. I have not been able to find any way of fixing this problem once the file has been opened in Xcode 12. After relaunching Xcode 13 and rerunning it there the black borders do not appear (but there are other problems I've run into that make me want to continue development in Xcode 12 for the project where I ran into this problem.)
Posted
by dsbirch.
Last updated
.
Post marked as solved
1 Replies
438 Views
I'm trying to learn how to use Combine in an AppKit app I'm working on. I found an Apple Developer article that explains pretty much exactly what I'm trying to achieve, delaying input from an NSTextField with the .debounce operator. (https://developer.apple.com/documentation/combine/receiving-and-handling-events-with-combine) Unfortunately it doesn't seem to be working for me. I have created a function in a NSTableCellView subclass that gets called as part of the cell's configuration which looks like:     private func watchForSearchTextEntries() { print("Setting up search text observer") let sub = NotificationCenter.default .publisher(for: NSControl.textDidChangeNotification, object: searchTermText) .map( { ($0.object as! NSTextField).stringValue } ) .sink(receiveCompletion: { print ($0) }, receiveValue: { print ($0) })  } When I run the app and type in that field, nothing gets printed to the Console. As a test, I also tried adding a NotificationCenter observer that calls a method to print out the notification's object. NotificationCenter.default.addObserver(self, selector: #selector(receivedTextChangeNotification(_:)), name: NSControl.textDidChangeNotification, object: searchTermText) That works as expected. So what's going on with my attempted use of Combine?
Posted
by dsbirch.
Last updated
.
Post marked as solved
2 Replies
3.5k Views
I've experienced repeatable crashes in an iOS app using KVO, and I'm wondering if anyone else is having the same issue. This is in Xcode 11 beta 7 running in Catalina beta 7 on the iPhone XR simulator. My project targets iOS 11 as a minimum deployment, but I was able to reproduce this issue in a very simple project that targets iOS 13.Here's the pertinent code from my simple demo:Create a class to observe:class ObservableObject: NSObject { dynamic var purchaseInProgress = false dynamic var wasPurchased = false var name = "" init(name: String) { self.name = name }}In a view controller, add an iVar for a strong reference to an observers array, and an array of observable objects: var observers = [NSKeyValueObservation]() var products = [ObservableObject]()Be sure to initialized the products array with some values: override func viewDidLoad() { super.viewDidLoad() products.append(ObservableObject(name: "Hot Fudge Sundae")) products.append(ObservableObject(name: "Deluxe Cheeseburger")) }Then add an outlet to a button that can trigger the action, and a method that should be called when an object is changed: @IBAction func setupObservers() { let purchaseProgressKeyPath = \ObservableObject.purchaseInProgress let wasPurchasedKeyPath = \ObservableObject.wasPurchased for product in products { self.observers.append(product.observe(purchaseProgressKeyPath, changeHandler: { (changedProduct, change) in self.productWasChanged(changedProduct) })) self.observers.append(product.observe(wasPurchasedKeyPath, changeHandler: { (changedProduct, change) in self.productWasChanged(changedProduct) })) } } @objc func productWasChanged(_ product: ObservableObject) { }Run the project and watch it crash with:Fatal error: Could not extract a String from KeyPath Swift.ReferenceWritableKeyPath<KVOCrash.ObservableObject, Swift.Bool>: file /BuildRoot/Library/Caches/com.apple.xbs/Sources/swiftlang_overlay_Foundation_Sim/swiftlang-1100.2.259.50/swift/stdlib/public/Darwin/Foundation/NSObject.swift, line 155At least that's my result. I hope this is something Apple needs to, and will, fix. This example is borrowed from more complex code that's working just fine in Xcode 10 but crashing in the Xcode 11 beta 7.
Posted
by dsbirch.
Last updated
.
Post not yet marked as solved
12 Replies
2.9k Views
I'm wondering if it's possible to save a new CKRecord to a custom zone and have iCloud automatically generate a record ID. I have my zones set up as I'd like. But if I save a new record to iCloud with the CKDatabase.save method, it saves it to the default zone, which is not where I want to save it. If I use a CKModifyRecordsOperation to save the record to its custom zone, it appears I first need to fully construct a CKRecord including a pre-defined record ID, and iCloud uses that record ID rather than generating one. Is there any way of achieving both of my goals other than auto-generating my own unique ID for each record?
Posted
by dsbirch.
Last updated
.
Post not yet marked as solved
2 Replies
1.2k Views
I've run into a problem in an iOS app I build originally with Xcode 8.In my main list view controller I've added a UITapGestureRecognizer to the navigationController's navigationBar to allow me to toggle the scroll position of the view's tableViewController to the end or the beginning of the list. In Xcode 9 betas where I've tested this (versions 1 and 6 I believe), the UIBarbuttonItems in my navigationController do not get touch events and so their actions are never called. I have tested this scenario by not adding the gesture recognizer to make sure that it wasn't just a problem with barButtonItems, and indeed they work just fine if there is no gesture recognizer in the navigationBar. But I would like to maintain this simple user experience, so removing the gesture recognizer or changing the required number of taps is undesirable.I filed a Radar for this issue when I first encountered it. It was closed as a duplicate but apparently no action has been taken in the intervening weeks.The best solution I've come up with is to test the touch location in the UIGestureRecognizerDelegate function gestureRecognizer:shouldReceiveTouch:, but it's a bit fragile, relying on some hard-coded values, and it doesn't provide consistent results.Can anybody suggest a better workaround?
Posted
by dsbirch.
Last updated
.