The block to use for reading the contents of the file handle asynchronously.
- iOS 5.0+
- macOS 10.7+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
The default value of this property is
nil. Assigning a valid Block object to this property creates a dispatch source for reading the contents of the file or socket. Your block is submitted to the file handle’s dispatch queue when there is data to read. When reading a file, your handler block is typically executed repeatedly until the entire contents of the file have been read. When reading data from a socket, your handler block is executed whenever there is data on the socket waiting to be read.
The block you provide must accept a single parameter that is the current file handle. The return type of your block should be
To stop reading the file or socket, set the value of this property to
nil. Doing so cancels the dispatch source and cleans up the file handle’s structures appropriately.