Post

Replies

Boosts

Views

Activity

@State variable not updating after fullscreencover shows for the first time
I have a fullscreencover that shows up when I press a button which reads values from another state variable, but when the fullscreencover shows up for the first time, it acts like the variable hasnt changed, and opening after that works perfectly. Here's some of my code: @State private var contextMenu = false @State private var selectedMessage: Message? List { ForEach(messages) { message in Button { selectedMessage = message contextMenu = true } label: { MessageItem(message: message) } .buttonStyle(.plain) } } .fullScreenCover(isPresented: $contextMenu, onDismiss: {selectedMessage = nil}) { var _ = print(selectedMessage) if let message = selectedMessage { VStack { Text("Select an action.") Text(message.content) HStack(alignment: .bottom) { Button { } label: { Image(systemName: "arrowshape.turn.up.left.fill") } Button { } label: { Image(systemName: "trash.fill") .foregroundColor(.red) } } } } else { Text("No message appears to be selected.") } } The first time the cover opens, it says "No message appears to be selected.", however on subsequent opens it displays the message and message content properly. It might be worth mentioning that I'm running this on watchOS, tested on a simulator and a real device, but I'm still getting the same issue.
1
0
631
Mar ’24
helper app error "embedded binary not signed with the same certificate as parent app"
Whenever I try to build my helper app, it fails with the error "Embedded binary not signed with the same certificate as parent app", however when I try to build it again, it works. This isn't really a problem for testing and prototyping, however when I try to make an archive of the app, it always fails, even though both apps are signed with the same certificate. I've tried getting it to work with automatic signing on and off, and while the main app builds flawlessly, the helper app still doesn't work. The only difference in the signing section of the app is the bundle identifier, which is just [mainapp]-helper (and also the "info" section but that shouldn't matter) In the build log, it also says Embedded Binary Signing Certificate: Not Code Signed Parent App Signing Certificate: Apple Distribution: [my name] (my team id) even though the helper app is signed.
5
0
1.7k
Aug ’22
helper app doesn't seem to be doing anything on login
I'm making an app that's meant to automatically log into school internet, and I'm trying to make it so that you save the credentials in the main app, and the helper app gets registered to launch at login, which works. However, when the helper app opens from logging in, it doesn't send a web request to log into the internet, but when I open the helper app manually, it does. Keep in mind that it's meant to send a request whenever the internet status changed to "connected" import Cocoa import Network @main class AppDelegate: NSObject, NSApplicationDelegate { let defaults = UserDefaults.init(suiteName: "replaced userdefaults group name thing") func applicationDidFinishLaunching(_ aNotification: Notification) { let usernamestored = defaults!.string(forKey: "username")! let passwordstored = String(decoding: kread(service: "detnsw-autologin", account: usernamestored)!, as: UTF8.self) // kread() refers to a function i have in another file for reading values from keychain let url = URL(string:"the login page url") guard let requestUrl = url else { fatalError() } var request = URLRequest(url: requestUrl) request.httpMethod = "POST" let poststring = "csrfmiddlewaretoken=&username=\(usernamestored)&password=\(passwordstored)" request.httpBody = poststring.data(using: String.Encoding.utf8) let task = URLSession.shared.dataTask(with: request) { (data, response, error) in if let error = error { print("Error took place \(error)") return } if let data = data, let _ = String(data: data, encoding: .utf8) { //print("Response data string:\n \(dataString)") //print(response.statusCode) } } let monitor = NWPathMonitor() monitor.pathUpdateHandler = { path in if path.status == .satisfied { task.resume() } } let queue = DispatchQueue(label: "Monitor") monitor.start(queue: queue) } func applicationWillTerminate(_ aNotification: Notification) { // Insert code here to tear down your application } func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { return true } }
1
0
367
Aug ’22