Functions

The following functions are available globally.

Functions

  • Returns a localized string representation of an AFNetworkReachabilityStatus value.

    Declaration

    Objective-C

    extern NSString *_Nonnull AFStringFromNetworkReachabilityStatus(
        AFNetworkReachabilityStatus status)

    Swift

    func AFStringFromNetworkReachabilityStatus(_ status: AFNetworkReachabilityStatus) -> String
  • Returns a percent-escaped string following RFC 3986 for a query string key or value. RFC 3986 states that the following characters are “reserved” characters.

    • General Delimiters: “:”, “#”, “[”, “]”, “@”, “?”, “/”
    • Sub-Delimiters: “!”, “$”, “&”, “‘”, “(”, “)”, “*”, “+”, “,”, “;”, “=”

    In RFC 3986 - Section 3.4, it states that the “?” and “/” characters should not be escaped to allow query strings to include a URL. Therefore, all “reserved” characters with the exception of “?” and “/” should be percent-escaped in the query string.

    Declaration

    Objective-C

    extern NSString *_Nonnull AFPercentEscapedStringFromString(
        NSString *_Nonnull string)

    Swift

    func AFPercentEscapedStringFromString(_ string: String) -> String

    Parameters

    string

    The string to be percent-escaped.

    Return Value

    The percent-escaped string.

  • A helper method to generate encoded url query parameters for appending to the end of a URL.

    Declaration

    Objective-C

    extern NSString *_Nonnull AFQueryStringFromParameters(
        NSDictionary *_Nonnull parameters)

    Swift

    func AFQueryStringFromParameters(_ parameters: [AnyHashable : Any]) -> String

    Parameters

    parameters

    A dictionary of key/values to be encoded.

    Return Value

    A url encoded query string

  • Recursively removes NSNull values from a JSON object.

    Declaration

    Objective-C

    extern id _Nonnull AFJSONObjectByRemovingKeysWithNullValues(
        id _Nonnull JSONObject, NSJSONReadingOptions readingOptions)

    Swift

    func AFJSONObjectByRemovingKeysWithNullValues(_ JSONObject: Any, _ readingOptions: JSONSerialization.ReadingOptions) -> Any