QueryItem
@propertyWrapper
public struct QueryItem<T> where T : QueryItemValue
extension QueryItem: Encodable where T: Encodable
A property wrapper that provides a convenient way to handle query items in a request.
Example usage:
@QueryItem(name: "search") var searchQuery: String
This property wrapper can be used to manage query items in a request.
-
The custom name of the query item, can be nil.
This property holds the custom name of the query item, which can be nil.
Declaration
Swift
public var name: String?
-
The wrapped value representing the query item value.
This property holds the wrapped value representing the query item value.
Declaration
Swift
public var wrappedValue: T
-
Initializes a new instance of
QueryItem
with the specified wrapped value.Example usage:
@QueryItem var searchQuery: String = "example"
Declaration
Swift
public init(wrappedValue: T)
Parameters
wrappedValue
The wrapped value representing the query item value.
-
Initializes a new instance of
QueryItem
with the specified name and default value.Example usage:
@QueryItem(name: "search") var searchQuery: String = "example"
Declaration
Swift
public init(name: String? = nil, defaultValue: T)
Parameters
name
The custom name of the query item, can be nil.
defaultValue
The default value representing the query item value.
-
Initializes a new instance of
QueryItem
with the specified name and a default value offalse
.Example usage:
@QueryItem(name: "isActive") var isActive: Bool
Declaration
Swift
public init(name: String?)
Parameters
name
The custom name of the query item, can be nil.
-
Initializes a new instance of
QueryItem
with the specified name and a nil value as the default value.Example usage:
@QueryItem(name: "isActive") var isActive: Bool?
Declaration
Swift
public init(name: String?)
Parameters
name
The custom name of the query item, can be nil.
-
Initializes a new instance of
QueryItem
with the specified name and a default value of0.0
.Example usage:
@QueryItem(name: "price") var price: Double
Declaration
Swift
public init(name: String?)
Parameters
name
The custom name of the query item, can be nil.
-
Initializes a new instance of
QueryItem
with the specified name and a nil value as the default value.Example usage:
@QueryItem(name: "price") var price: Double?
Declaration
Swift
public init(name: String?)
Parameters
name
The custom name of the query item, can be nil.
-
Initializes a new instance of
QueryItem
with the specified name and a nil value as the default value.Example usage:
@QueryItem(name: "count") var count: Int?
Declaration
Swift
public init(name: String?)
Parameters
name
The custom name of the query item, can be nil.
-
Initializes a new instance of
QueryItem
with the specified name and an empty string as the default value.Example usage:
@QueryItem(name: "search") var searchQuery: String
Declaration
Swift
public init(name: String?)
Parameters
name
The custom name of the query item, can be nil.
-
Initializes a new instance of
QueryItem
with the specified name and a nil value as the default value.Example usage:
@QueryItem(name: "search") var searchQuery: String?
Declaration
Swift
public init(name: String?)
Parameters
name
The custom name of the query item, can be nil.
-
Initializes a new instance of
QueryItem
with the specified name and a nil value as the default value.Example usage:
@QueryItem(name: "status") var status: MyEnum?
Declaration
Swift
public init(name: String?)
Parameters
name
The custom name of the query item, can be nil.