How to pass one SwiftUI View as a variable to another View struct

To sum up everything I read here and the solution which worked for me: struct ContainerView<Content: View>: View { @ViewBuilder var content: Content var body: some View { content } } This not only allows you to put simple Views inside, but also, thanks to @ViewBuilder, use if-else and switch-case blocks: struct SimpleView: View { … Read more

What is SOCK_DGRAM and SOCK_STREAM?

TCP almost always uses SOCK_STREAM and UDP uses SOCK_DGRAM. TCP (SOCK_STREAM) is a connection-based protocol. The connection is established and the two parties have a conversation until the connection is terminated by one of the parties or by a network error. UDP (SOCK_DGRAM) is a datagram-based protocol. You send one datagram and get one reply … Read more

How can I send and receive WebSocket messages on the server side?

Note: This is some explanation and pseudocode as to how to implement a very trivial server that can handle incoming and outcoming WebSocket messages as per the definitive framing format. It does not include the handshaking process. Furthermore, this answer has been made for educational purposes; it is not a full-featured implementation. Specification (RFC 6455) … Read more

Can a category implement a protocol in Objective C?

Yes, that’s possible. The syntax is: @interface NSDate (CategoryName) <ProtocolName> @end @implementation NSDate (CategoryName) @end Here’s Apple’s documentation on the topic. It’s also possible to do this using a class extension. I very much like this to privately conform to delegate protocols. Doing so hides the implementation detail of being some delegate of some class … Read more

DHT in torrents

With trackerless/DHT torrents, peer IP addresses are stored in the DHT using the BitTorrent infohash as the key. Since all a tracker does, basically, is respond to put/get requests, this functionality corresponds exactly to the interface that a DHT (distributed hash table) provides: it allows you to look up and store IP addresses in the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)