Post

Replies

Boosts

Views

Activity

How to programatically remove NSValueTransformer Binding
I'm binding a value transformer like this: optionsDict = [NSBindingOption.valueTransformer:decToHexTransformer(), NSBindingOption.valueTransformerName:NSValueTransformerName.decToHexTransformerName] plcAddrLabel.bind(.value, to: self, withKeyPath: "plcRegisterAddress" , options: optionsDict) To remove the transformer I have tried this: plcAddrLabel.unbind(.value) plcAddrLabel.bind(.value, to: self, withKeyPath: "plcRegisterAddress" , options: nil) but the transformer is still present after the bind operation, it appears unbind doesn't remove it. and I tried this: optionsDict = [NSBindingOption.valueTransformer: "<null>", NSBindingOption.valueTransformerName: "<null>"] plcAddrLabel.bind(.value, to: self, withKeyPath: "plcRegisterAddress" , options: optionsDict) which immediately triggers the error -[NSTaggedPointerString transformedValue:]: unrecognized selector sent to instance upon execution of the bind function. same error is caused with this code: optionsDict = [NSBindingOption.valueTransformer: NSBindingOption.nullPlaceholder, NSBindingOption.valueTransformerName: NSBindingOption.nullPlaceholder] Is there a way to programatically remove a transformer from a binding?
0
0
399
Jun ’22
NWConnection - receive() timeout/cancel
How can one implement a connection to a serial terminal server? Sending data to the terminal server is easy but receiving data back from the terminal server is not as the receive command can't be aborted and the NWConnection is considered unusable once a receive has timed out as explained by @eskimo in this thread: https://developer.apple.com/forums/thread/120438. Any NWConnection use case where the NWEndpoint represents a network media transition point (Ethernet->Serial in case of serial terminal server) must be ready to receive data but the time for receiving is not predictable and not receiving any data for an extended period of time is normal and does not reflect a failure at the NWEndpoint hence should not affect the NWConnection state. This example becomes even more pertinent when the terminal server connects to a multi drop serial network (e.g. RS485) with multiple devices connected where some of the serial devices may not respond at all (e.g. when powered down). Combined with quick data update times (e.g. 100ms) the problem becomes insurmountable as cancelling the connection (to abort receive) every time a device doesn't respond, will cause lots of unnecessary network traffic. The only solution I can think of is for NWConnection provide the ability to abort receive() without affecting the NWConnection. For anyone that thinks "Serial is old, nobody uses it today" - There are tens of thousands of devices in industrial applications which use serial communications and it is essential that modern support software is made available on macOS. Any suggestions would be much appreciated.
1
0
720
Aug ’22