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
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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.
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?
How to reproduce:
Launch ptt app
join channel
call requestBeginTransmitting
in delegate method didActivate audioSession prepare AVAudioRecorder and call record
Error: AVAudioRecorder.record() returns false
If I reinstantiate and run AVAudioRecorder.record() right away then it returns true. It happens only on first audio recording after app launch.