NSString(APString) Category Reference
Declared in | NSString+APString.h |
Overview
A library of helpful additions to the NSString class to simplify common tasks within Appacitive-iOS-SDK
Tasks
-
– stringByAppendingQueryParameters:
Returns a resource path from a dictionary of query parameters URL encoded and appended This is a convenience method for constructing a new resource path that includes a query. For example, when given a resourcePath of /contacts and a dictionary of parameters containing foo=bar and color=red, will return /contacts?foo=bar&color=red
-
– appendQueryParams:
-
– queryParameters
Returns a dictionary of parameter keys and values using UTF-8 encoding given a URL-style query string on the receiving object. For example, when given the string /contacts?foo=bar&color=red, this will return a dictionary of parameters containing foo=bar and color=red, excluding the path “/contacts?”
-
– queryParametersUsingEncoding:
Returns a dictionary of parameter keys and values given a URL-style query string on the receiving object. For example, when given the string /contacts?foo=bar&color=red, this will return a dictionary of parameters containing foo=bar and color=red, excludes the path “/contacts?”
-
– queryParametersUsingArrays:encoding:
Returns a dictionary of parameter keys and values arrays (if requested) given a URL-style query string on the receiving object. For example, when given the string /contacts?foo=bar&color=red, this will return a dictionary of parameters containing foo=[bar] and color=[red], excludes the path “/contacts?”
-
– stringByAddingURLEncoding
Returns a URL encoded representation of self.
Instance Methods
queryParameters
Returns a dictionary of parameter keys and values using UTF-8 encoding given a URL-style query string on the receiving object. For example, when given the string /contacts?foo=bar&color=red, this will return a dictionary of parameters containing foo=bar and color=red, excluding the path “/contacts?”
- (NSDictionary *)queryParameters
Parameters
- receiver
A string in the form of @“/object/?sortBy=name”, or @“/object/?sortBy=name&color=red”
Return Value
A new dictionary of query parameters, with keys like ‘sortBy’ and values like ‘name’.
Discussion
Returns a dictionary of parameter keys and values using UTF-8 encoding given a URL-style query string on the receiving object. For example, when given the string /contacts?foo=bar&color=red, this will return a dictionary of parameters containing foo=bar and color=red, excluding the path “/contacts?”
Declared In
NSString+APString.h
queryParametersUsingArrays:encoding:
Returns a dictionary of parameter keys and values arrays (if requested) given a URL-style query string on the receiving object. For example, when given the string /contacts?foo=bar&color=red, this will return a dictionary of parameters containing foo=[bar] and color=[red], excludes the path “/contacts?”
- (NSDictionary *)queryParametersUsingArrays:(BOOL)shouldUseArrays encoding:(NSStringEncoding)encoding
Parameters
- shouldUseArrays
If NO, it yields the same results as queryParametersUsingEncoding:, otherwise it creates value arrays instead of value strings.
- encoding
The encoding for to use while parsing the query string.
- receiver
A string in the form of @“/object?sortBy=name”, or @“/object?sortBy=name&color=red”
Return Value
A new dictionary of query parameters, with keys like ‘sortBy’ and value arrays (if requested) like [‘name’].
Discussion
Returns a dictionary of parameter keys and values arrays (if requested) given a URL-style query string on the receiving object. For example, when given the string /contacts?foo=bar&color=red, this will return a dictionary of parameters containing foo=[bar] and color=[red], excludes the path “/contacts?”
This method originally appeared as queryContentsUsingEncoding: in the Three20 project: https://github.com/facebook/three20/blob/master/src/Three20Core/Sources/NSStringAdditions.m
See Also
Declared In
NSString+APString.h
queryParametersUsingEncoding:
Returns a dictionary of parameter keys and values given a URL-style query string on the receiving object. For example, when given the string /contacts?foo=bar&color=red, this will return a dictionary of parameters containing foo=bar and color=red, excludes the path “/contacts?”
- (NSDictionary *)queryParametersUsingEncoding:(NSStringEncoding)encoding
Parameters
- receiver
A string in the form of @“/object/?sortBy=name”, or @“/object/?sortBy=name&color=red”
- encoding
The encoding for to use while parsing the query string.
Return Value
A new dictionary of query parameters, with keys like ‘sortBy’ and values like ‘name’.
Discussion
Returns a dictionary of parameter keys and values given a URL-style query string on the receiving object. For example, when given the string /contacts?foo=bar&color=red, this will return a dictionary of parameters containing foo=bar and color=red, excludes the path “/contacts?”
This method originally appeared as queryContentsUsingEncoding: in the Three20 project: https://github.com/facebook/three20/blob/master/src/Three20Core/Sources/NSStringAdditions.m
Declared In
NSString+APString.h
stringByAddingURLEncoding
Returns a URL encoded representation of self.
- (NSString *)stringByAddingURLEncoding
Discussion
Returns a URL encoded representation of self.
Declared In
NSString+APString.h
stringByAppendingQueryParameters:
Returns a resource path from a dictionary of query parameters URL encoded and appended This is a convenience method for constructing a new resource path that includes a query. For example, when given a resourcePath of /contacts and a dictionary of parameters containing foo=bar and color=red, will return /contacts?foo=bar&color=red
- (NSString *)stringByAppendingQueryParameters:(NSDictionary *)queryParameters
Parameters
- queryParameters
A dictionary of query parameters to be URL encoded and appended to the resource path
Return Value
A new resource path with the query parameters appended
Discussion
Returns a resource path from a dictionary of query parameters URL encoded and appended This is a convenience method for constructing a new resource path that includes a query. For example, when given a resourcePath of /contacts and a dictionary of parameters containing foo=bar and color=red, will return /contacts?foo=bar&color=red
NOTE – Assumes that the resource path does not already contain any query parameters.
Declared In
NSString+APString.h