Initializes a newly allocated query item with the specified name and value.


init(name: String, value: String?)



The name of the query item. For example, in the URL, the name parameter is q.


The value for the query item. For example, in the URL, the value parameter is iPad.

Return Value

An initialized query item object.


To use the newly initialized query item in composing a URL, add it to the queryItems array of an NSURLComponents instance. Because assigning an array of query items to an NSURLComponents instance automatically encodes the name and value properties, you should not percent-encode these strings.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software