Initializer

init(stringLiteral:)

Creates an instance initialized to the given string value.

Declaration

init(stringLiteral value: String)

Discussion

Do not call this initializer directly. It is used by the compiler when you initialize a string using a string literal. For example:

let nextStop = "Clark & Lake"

This assignment to the nextStop constant calls this string literal initializer behind the scenes.

Relationships

See Also

Infrequently Used Functionality

func index(of: Character) -> Index?

Returns the first index where the specified value appears in the collection.

Deprecated
init(stringInterpolation: DefaultStringInterpolation)

Creates a new instance from an interpolated string literal.

init(unicodeScalarLiteral: String)

Creates an instance initialized to the given value.

init(extendedGraphemeClusterLiteral: String)

Creates an instance initialized to the given value.

var customPlaygroundQuickLook: _PlaygroundQuickLook

A custom playground Quick Look for the String instance.

Deprecated
func withContiguousStorageIfAvailable<R>((UnsafeBufferPointer<Character>) -> R) -> R?

Call body(p), where p is a pointer to the collection’s contiguous storage. If no such storage exists, it is first created. If the collection does not support an internal representation in a form of contiguous storage, body is not called and nil is returned.