Type Method

queryItemWithName:value:

Creates a new query item with the specified name and value.

Declaration

+ (instancetype)queryItemWithName:(NSString *)name value:(NSString *)value;

Parameters

name

The name of the query item. For example, in the URL http://www.apple.com/search/?q=iPad, the name parameter is q.

value

The value for the query item. For example, in the URL http://www.apple.com/search/?q=iPad, the value parameter is iPad.

Return Value

A new query item object.

Discussion

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.

See Also

Creating a Query Item

- initWithName:value:

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