Instance Method

data(using:)

Returns an NSData object containing a representation of the receiver encoded using a given encoding.

Declaration

func data(using encoding: UInt) -> Data?

Parameters

encoding

A string encoding. For possible values, see NSStringEncoding.

Return Value

The result of invoking data(using:allowLossyConversion:) with false as the second argument (that is, requiring lossless conversion).

See Also

Working with Encodings

class var availableStringEncodings: UnsafePointer<UInt>

Returns a zero-terminated list of the encodings string objects support in the application’s environment.

class var defaultCStringEncoding: UInt

Returns the C-string encoding assumed for any method accepting a C string as an argument.

class func localizedName(of: UInt) -> String

Returns a human-readable string giving the name of a given encoding.

func canBeConverted(to: UInt) -> Bool

Returns a Boolean value that indicates whether the receiver can be converted to a given encoding without loss of information.

func data(using: UInt, allowLossyConversion: Bool) -> Data?

Returns an NSData object containing a representation of the receiver encoded using a given encoding.

var description: String

This NSString object.

var fastestEncoding: UInt

The fastest encoding to which the receiver may be converted without loss of information.

var smallestEncoding: UInt

The smallest encoding to which the receiver can be converted without loss of information.

NSString Handling Exception Names

These constants define the names of exceptions raised if NSString cannot represent a string in a given encoding, or parse a string as a property list.