Post

Replies

Boosts

Views

Activity

How to Set White Balance?
Here is a code snippet by which I attempted to set a neutral white balance: func prepare(completionHandler: @escaping (Error?) -> Void) { func createCaptureSession() { self.captureSession = AVCaptureSession() } func configureCaptureDevices() throws { let session = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .back) let cameras = (session.devices.compactMap { $0 }) if cameras.isEmpty { throw CameraControllerError.noCamerasAvailable } for camera in cameras { try camera.lockForConfiguration() camera.setWhiteBalanceModeLocked( with whiteBalanceGains: AVCaptureDevice.WhiteBalanceGains( redGain: 1.0, greenGain: 1.0, blueGain: 1.0), completionHandler handler: ((CMTime) -> Void)? = nil ) // Errors: Extra arguments at positions #2, #3 in call, Cannot find 'with' in scope camera.whiteBalanceMode = .locked camera.unlockForConfiguration() }catch{ // To Do: Error handling here } } My call to "AVCaptureDevice.WhiteBalanceGains()" gets errors. What is the correct way to do this?
0
0
642
Jun ’23
Can @AppStorage be used on Storyboard objects?
The need is to persist between launches the state of storyboard objects such as of type UISwitch, UITextField, etc. Can this be done using @AppStorage? If so how can @AppStorage be set to watch these? I tried getting @AppStorage to watch an outlet class member variable that is connected to the storyboard object: @IBOutlet weak var iPhoneName: UITextField! @AppStorage("iPhoneName") var iPhoneName: String = "" This got an error because the variable to be watched is already declared. I decided to make the the watched variable different than the one connected to the Storyboard's UITextField object: @AppStorage("iPhoneName") var striPhoneName: String = "" and got the error: Unknown attribute 'AppStorage' . In what import library is @AppStorage defined? If @AppStorage cannot be used for this, what is the easiest way to code storyboard object persistence? I am looking for an easy, and quick way. I am not concerned with memory usage right now.
2
0
1.5k
Jun ’23
Accessing Interface Builder GUI Controls Anywhere in the App
I used the Interface Builder to place a Switch object in a view. I ctrl dragged it into the Assistant to make its handler a method of the class the view's is in, which is itself a subclass of "UITableViewController". A dialog box appear into which I entered the function name, and select the the option to have the sender as an argument. The result is function of the form: @IBAction func switchStateChange(_ sender: UISwitch) { } Now I need to query this Switch's On/Off state from elsewhere in the program, and if necessary change its state. It is not a good solution to save the sender parameter to a global variable because then it would require the user to change this switch's state before that global variable is set. What is needed is to identify, and lookup, this switch object to access it from anywhere in the application. How is this done?
1
0
645
Jun ’23
Storyboard Boolean Switch Object
The Storyboard Interface Builder has a Switch object that toggles between On, and Off, states. While in the On state it looks normal. While in the Off state it is grayed out. I have a use for this object for the user to toggle between two options which are other than On, and Off. For my intended use its Off state gray out is undesirable. Is there way to prevent this switch graying out in its Off state?
0
0
344
Jun ’23
Every added View Controller adds a Launch Screen
I am still very new to Swift. Now I am learning about storyboards. I added two View Controllers to the app by using the + icon in Xcode's Title Bar. Added one button to each of their screens, and then added a connectors (segues) between them, so that each button would navigate to the other screen. As soon as these connectors are added, each segue gets the error: /Users/ ... /LaunchScreen.storyboard Launch screens may not have triggered segues. So I figured at first that the first screen I added to the project by means of adding a View Controller must have been launch screen. So I remove the segues, I add two more screens in the same way, and make the same connections between these two new screens. The same errors appeared. It appears to me that Xcode considers every new screen added by dragging in a View Controller is a launch screen. How do I make only the first screen the "Launch Screen"?
1
0
745
Jun ’23
case keyword used without switch
In TicTacToe example there is in the override method "PasscodeViewController.viewDidLoad()" this snippet of code: if let browseResult = browseResult, case let NWEndpoint.service(name: name, type: _, domain: _, interface: _) = browseResult.endpoint { title = "Join \(name)" } What confuses me: The use of the "case" keyword without a switch statement. The "case" keyword does not have a constant to compare with to decide if will branch here. And what of the method call to NWEndpoint.service() being set equal to something? Is this actually defining what the service method will do when the system calls it?
9
0
992
Jun ’23
Reconfirming the DNS the Record
On the 4th question of: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/NetServices/Articles/faq.html I see: "you can ask the Bonjour to reconfirm the record" I am basing my code on the TicTacToe example at: https://developer.apple.com/videos/play/wwdc2022/110339/ I believe the DNS records which remains after the device that put them there shuts down is causing problems for me when again. Using the DeviceDiscoveryUI as in that TicTacToe example how are these records "reconfirmed" ?
3
0
747
Jun ’23
Phantom Service
To learn how to do peer to peer communication I downloaded the TicTacToe example into my MacStudio from: https://developer.apple.com/documentation/network/building_a_custom_peer-to-peer_protocol I then loaded it into Xcode, compiled it, deployed to an iPhone 14 over a Lightning cable, and ran it. I developed code for the MacStudio in an attempt to communicate with it. The MacStudio at first detected the service but for some reason it has quit doing so. The command: dns-sd -B _services._dns-sd._udpoutputs this as one of its lines: A/R Flags if Domain Service Type Instance Name Add 3 17 . tcp.local. _tictactoe (The time stamp column deleted for clarity) This line remains the command's output even after the iPhone the TicTacToe app has been shutdown, and after in the MacStudio Xcode, and the simulator it opens, is shutdown. In an attempt to find out what application is still advertising this Bonjour service I installed Discovery from: https://apps.apple.com/us/app/discovery-dns-sd-browser/id305441017 When run the _tictactoe service instance does show in its list also also. But when I left click this item in that list to get a detail view of it I get a perpetual spinning wheel, and just to the right of it the message "Scanning...". No information is displayed. What does that mean in regard to what program is still advertising this service? What other ways are available to find this program so it can be shut down? Is it possible that this presence in that list, and in the output of the dns-sd is just a phantom vestige of an application that is not longer running? If this is a case how can the service offering be shutdown?
1
0
393
Jun ’23
Mystery Startup Applications
On my MacStudio there are applications that start up when on login. I need to these not to be. No applications show up at: System Settings => General => Login Items Where else is there to look? The startup apps that are opening are: iPhone 14 Pro simulator Activity Monitor I believe the simulator is opening because I have been developing an iPhone 14 app with XCode. But once started, somehow, like the Sorcerer's Apprentice's brooms, it just keeps on appearing on its own, even if I have closed both it, and XCode, before shutdown. So now, to keep this off at startup, I need a sorcerer?
0
0
267
Jun ’23