Instance Method

startStreamWithName:toPeer:error:

Opens a byte stream to a nearby peer.

Declaration

- (NSOutputStream *)startStreamWithName:(NSString *)streamName toPeer:(MCPeerID *)peerID error:(NSError * _Nullable *)error;

Parameters

streamName

A name for the stream. This name is provided to the nearby peer.

peerID

The ID of the nearby peer.

error

The address of an NSError pointer where an error object should be stored if something goes wrong.

Return Value

An output stream object upon success or nil if a stream could not be established.

Discussion

This method is nonblocking.

For more information about performing networking with input and output streams, read Networking Programming Topics.

See Also

Sending Data and Resources

- sendData:toPeers:withMode:error:

Sends a message encapsulated in an NSData object to nearby peers.