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?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
The function:
browseResultsChangedHandler: ((_ newResults: Set<NWBrowser.Result>, _ changes: Set<NWBrowser.Result.Change>) -> Void)?
returns two Set type parameters. There is data in each element of these sets I need to display in a view. What is the best way to convert these sets to an array that can be iterated in a "ForEach" statement so they can be displayed in a View?
When I attempt to do it on a set directly I get the error:
Cannot convert value of type 'Set<NWBrowser.Result>' to expected argument type 'Range<Int>'
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" ?
In the example code in this thread:
https://stackoverflow.com/questions/61235935/understanding-some-nwbrowser-i-managed-to-get-working
there is this line:
print("result ", result )
The second argument in the print statement, the "result" variable, is not a String type. It is instead a struct whose definition begins in line 10731 in the "Network" import file. Somehow the print function knows how to convert this into a string for printing to the terminal. I conclude, with some uncertainty, that the instructions for doing this conversion have to be defined in this struct. Where in this struct is the conversion defined? If not defined there, how is the conversion done?
The need is to take pictures with Swift code settable parameters such as F-Stop, exposure time, and zoom level, in an iPhone 14 Pro.
What AVCam methods control these? If there are none, are there other ways to do this?
The option to have the torch constantly light on, or off, is also needed. Flash will not be used.
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.
I added a scene to an existing story board that already has other scenes. I put focus on the new scene, and in the Identity Inspector's "Class" field I gave it a class name. The "Storyboard ID" field did not show in this inspector. Why would it not?
No file named after the class name I gave it appeared in the "Project navigator". Is this supposed to happen automatically? Or must I create this Swift file that contains the class definition for the scene manually?
I have a UITextField object in a storyboard's scene where the user is make numeric entries. Because this field is for numbers only I set the keyboard type to "Number Pad" in attributes. But this keyboard does not have a return key which leaves the user unable to signal when the entry is complete, the keyboard should be put away, and the entered value processed. I tried all the other numeric keyboards also, and found that none of them has a return key. The default keyboard does, but it is a full alphanumeric keyboard which is undesirable for that field.
How can I cause the return key, done key, or whichever does that function, appear on a numeric only keyboard?
The need is to control the cameras, and LIDAR, on up to four iPhone 14 Pros from at Mac Studio they are connected to. The data from the iPhones is to be uploaded from the iPhone 14s to the MacStudio for processing. What I need help with is:
How can the iPhone 14s connected to MacStudio be enumerated on the Mac Studio to know how many there, are and their communication handles?
How can the camera application that takes the photos, and the other that takes LIDAR data, be communicated with over the Lighting Cables to send commands from the Mac Studio, and to transfer the image, and lidar, data files?
1 The iPhones will have to route commands sent over lighting cables from the Mac Studio to the appropriate application for camera, and LIDAR. What is the best way to do this routing?
To save time I will be basing the software on the iPhones on these sample projects which I will modify to meet the project's needs:
https://developer.apple.com/documentation/avfoundation/capture_setup/avcam_building_a_camera_app
https://developer.apple.com/documentation/avfoundation/additional_data_capture/capturing_depth_using_the_lidar_camera
Parameters I need to directly control from the Mac Studio are exposure times, F stops, which of the iPhones will flash. Each connected iPhone's camera must be triggered as simultaneously as possible.
I am very new to Swift, and OSX. I have read the Swift manual, and done the iOS App Dev Tutorials.
In this thread, eskimo posted code containing the line:
listener.service = .init(type: "_ssh._tcp")
I see in this document the type parameter is a service string, where its first substring identifies the application protocol, and its second identifies the transport protocol.
Where is it documented what the valid NWListener.listener.service string options are for these application, and transport, protocols?
These are download links to zip files that contain Xcode 14.3 project files which are my attempt to establish USB communications with an iPhone 14 connected by lightning cable to a MacStudio:
https://www.mediafire.com/file/k3my6y94iyjobeq/Bonjour-Trial-iPhone.zip/file
https://www.mediafire.com/file/cof3b3w9tru1jd0/Bonjour-Trial-Mac-Enumeration.zip/file
I could not attach them here. This web interface's file browser had these files grayed out, so it was necessary to make them available on a file sharing site.
The Bonjour-Trial-iPhone.zip project files run on the iPhone 14. The Bonjour-Trial-Mac-Enumeration.zip run on the MacStudio.
I have the iPhone 14 project code working on the iPhone. I expect it should be advertising its presence.
MacStudio project runs, but does not find the iPhone 14. When I trace execution in file Bonjour-Trial-Mac-Enumeration.swift the "results" array is empty on line 65.
What is going wrong here? Is a type "_ssh._tcp" connection possible between a MacStudio, and an iPhone, over the lightning cable?
The Info.plist file is missing from my project as shown in this screenshot:
Yet the project has properties as the screenshot does show. So obviously the properties are being remembered somewhere, and I do not know where. As can be seen no paths to an Info.plist is currently set.
I need to create a new Info.plist file, and add it to the project. My concern now is about synchronization. If I were to do this by navigating to: File => New => File => Resource => Property List, and named it Info.plist, will this new property list file automatically synchronized with all of my current settings? Or would it contain only default settings, and synchronize my project's settings with those default settings?
I suspect the original Info.plist file was lost when I decided rename folders, and filenames, and had to copy everything into a new project to do that. I failed to copy over the Info.plist file.
Is there a setting in the iPhone 14's iOS that allows the flashlight (torch) remain on simultaneously with the camera taking a still shot?
If not, is there an app that can do that?
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?
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"?