cString()
Returns a representation of the receiver as a C string in the default C-string encoding.
Declaration
func cString() -> UnsafePointer<CChar>?Discussion
The returned C string will be automatically freed just as a returned object would be released; your code should copy the C string or use getCString(_:) if it needs to store the C string outside of the autorelease context in which the C string is created.
Raises an NSCharacterConversionException if the receiver can’t be represented in the default C-string encoding without loss of information. Use canBeConverted(to:) if necessary to check whether a string can be losslessly converted to the default C-string encoding. If it can’t, use lossyCString() or data(using:allowLossyConversion:) to get a C-string representation with some loss of information.
See Also
Related Documentation
Deprecated
string(withCString:)init(CString:)string(withCString:length:)init(CString:length:)init(CStringNoCopy:length:freeWhenDone:)string(withContentsOfFile:)init(contentsOfFile:)string(withContentsOf:)init(contentsOfURL:)write(toFile:atomically:)write(to:atomically:)getCharacters(_:)lossyCString()cStringLength()getCString(_:)