Type Method

writeJSONObject:toStream:options:error:

Writes a given JSON object to a stream.

Declaration

+ (NSInteger)writeJSONObject:(id)obj toStream:(NSOutputStream *)stream options:(NSJSONWritingOptions)opt error:(NSError * _Nullable *)error;

Parameters

obj

The object to write to stream.

stream

The stream to which to write.

The stream should be opened and configured.

opt

Options for writing the JSON data.

See NSJSONWritingOptions for possible values.

error

If an error occurs, upon return contains an NSError object with code NSPropertyListWriteInvalidError that describes the problem.

Return Value

The number of bytes written to the stream, or 0 if an error occurs.

See Also

Creating JSON Data

+ dataWithJSONObject:options:error:

Returns JSON data from a Foundation object.

+ isValidJSONObject:

Returns a Boolean value that indicates whether a given object can be converted to JSON data.