Converts the receiver’s content to the default C-string encoding and stores them in a given buffer.
Deprecated
Use get instead.
SDKs
- iOS 2.0–2.0Deprecated
- macOS 10.0–10.4Deprecated
- Mac Catalyst 13.0–13.0Deprecated
- tvOS 9.0–9.0Deprecated
- watchOS 2.0–2.0Deprecated
Framework
- Foundation
Declaration
func getCString(_ bytes: Unsafe Mutable Pointer<Int8>, maxLength: Int, range aRange: NSRange, remaining leftoverRange: NSRange Pointer?)
Discussion
buffer must be large enough to contain max bytes plus a terminating zero character (which this method adds). Copies and converts as many characters as possible from a and stores the range of those not converted in the range given by leftover (if it’s non-nil). Raises an NSRange if any part of a lies beyond the end of the string.
Raises an NSCharacter if the receiver can’t be represented in the default C-string encoding without loss of information. Use can if necessary to check whether a string can be losslessly converted to the default C-string encoding. If it can’t, use lossy or data(using: to get a C-string representation with some loss of information.