Post

Replies

Boosts

Views

Activity

SwiftUI: reference types leaks memory when used in State property wrapper.
In next program SimpleClass do not call deinit causing memory leak. final class SimpleClass {     deinit {         print("deinit SimpleClass")     } } struct ContentView: View {     var body: some View {         Text("Empty")             .onAppear {                 simple = .init()             }     }     @State private var simple = SimpleClass() } Tested on iPhone 12 mini, iOS 16.2, Version 14.2 (14C18). Am I using @State wrapper wrong?
2
0
1.3k
Feb ’23
AVCapturePhotoOutput image orientation not changes.
Hello, I'm trying to replicate UIImagePickerController photo taking ability with AVFoundation. What I do: invoke `photoOutput.capturePhoto(with, delegate) in delegate method photoOutput(_:didFinishProcessingPhoto:error:)) I retrieve UIImage with photo.fileDataRepresentation() The issue: Produced UIImage has imageOrientation == .right, always. At the same time if I use UIImagePickerController, and say put my iPhone in landscape right position then produced image in its delegate has correct imageOrientation == .down. How can I achieve the same results with AVFoundation given that my iPhone orientation is locked (so UIDevice.orientation will not work). So far my best guess that I need to use accelerometer for this but maybe I miss some setting which allows to recover correct image orientation? Thank you.
0
0
645
Jan ’23
Connect to local network device knowing only port it runs on.
Hi, Objective: iOS 14, iPhone needs to connect to device on local network without knowing its hostname; only port is known. Do I understand it correctly that the only way to do it is to request com.apple.developer.networking.multicast entitlement and execute: guard let multicast = try? NWMulticastGroup(for: [ .hostPort(host: "224.0.0.251", port: 5353) ]) else { fatalError(...) } let group = NWConnectionGroup(from: multicast, using: .udp) group.setReceiveHandler(maximumMessageSize: 16384, rejectOversizedMessages: true) { (message, content, isComplete) in print("Received message from \(String(describing: message.remoteEndpoint))") } Then from message.remoteEndpoint I can infer hostname (with matching port, of course) to which I need initiate NWConnection? Thanks Code source - https://developer.apple.com/news/?id=0oi77447
2
0
837
Apr ’21