Posts

Post not yet marked as solved
2 Replies
749 Views
tl;dr - I've got a data model class and a Multipeer controller class. I would like to access my data model from the (non-view)Multipeer controller class. I'm working on a tvOS app that will display data in a certain way. The data is in my class model which has all vars @Published. The Class is declared a @StateObject in my base app file and passed to the views as an .environmentObject. This works fine for accessing/changing values in the data model from any view. I have another Class defined that establishes a Multipeer Connectivity connection to peers and listens for data to be sent. When the data is sent I decode it into my data model Class. This works fine. The problem is that I need to stuff these received values into the StateObject data structure that all the views use. I have not successfully been able to do that. Any suggestions on how to get the data I've received in this one class into the "global" data structure that the Views access?
Posted
by botofogo.
Last updated
.
Post marked as solved
3 Replies
951 Views
I'm trying to provide a mechanism for the user to select a bg image from their photo library. I've got this code which theoretically is getting the data but can't figure out how to convert it to an Image in SwiftUI. I've found plenty of examples on iOS but none workable on MacOS. This is my implementation of the PhotosPicker on iOS: PhotosPicker(selection: $vm.selectedBGphoto, matching: .images) { Label("Select Background Image", systemImage: "photo.on.rectangle") } .tint(.purple) .controlSize(.large) .onChange(of: vm.selectedBGphoto) { newItem in Task { if let data = try? await newItem?.loadTransferable(type: Data.self) { if let uiImage = UIImage(data: data) { vm.selectedBGdata = data vm.bgImage = Image(uiImage: uiImage) } } } This DOES NOT work on MacOS because of the UIImage reference. How do I convert what I get from PhotosPicker into an Image on MacOS?
Posted
by botofogo.
Last updated
.
Post not yet marked as solved
0 Replies
544 Views
I want to present content from my iOS app to a display (ie SmartTV) via AirPlay. I've searched the Apple doc and have done Google searches, but I can't find any decent examples of how to get started with connecting to a remote display. Everything seems to be either out of date or too small a snippet to be of use (no context as to where the snippet might go in your code). Can someone please show me how to connect my SwiftUI app to a remote display? It would be greatly appreciated.
Posted
by botofogo.
Last updated
.