Initializer

init(object:)

Creates and returns an array containing a given object.

Declaration

convenience init(object anObject: Any)

Parameters

anObject

An object.

Return Value

An array containing the single element anObject.

Discussion

Alternatively, you can use array literal syntax in Objective-C or Swift to create an array containing a given object:

let array: NSArray = ["Hello, world!"]

See Also

Creating an Array

init(objects: UnsafePointer<AnyObject>, count: Int)

Creates and returns an array that includes a given number of objects from a given C array.