NSString(HBAdditions)

@interface NSString (HBAdditions)

NSString (HBAdditions) is a class category in Cephei that provides some convenience methods.

  • Returns a string encoded for an HTTP query parameter.

    This method encodes a variety of symbols that can conflict with other portions of a URL, such as & and =, and other similar symbols that could otherwise be misinterpreted by some implementations.

    Declaration

    Objective-C

    - (nonnull NSString *)hb_stringByEncodingQueryPercentEscapes;

    Swift

    func hb_stringByEncodingQueryPercentEscapes() -> String

    Return Value

    A string encoded for an HTTP query parameter.

  • Returns a string decoded from an HTTP query parameter.

    This method decodes percent escapes, as well as spaces encoded with a +.

    Declaration

    Objective-C

    - (nonnull NSString *)hb_stringByDecodingQueryPercentEscapes;

    Swift

    func hb_stringByDecodingQueryPercentEscapes() -> String

    Return Value

    A string decoded from an HTTP query parameter.

  • Returns a dictionary containing the HTTP query parameters in the string.

    The string is expected to be in the format key=value&key=value, with both keys and values encoded where necessary.

    Declaration

    Objective-C

    - (nonnull NSDictionary *)hb_queryStringComponents;

    Swift

    func hb_queryStringComponents() -> [AnyHashable : Any]

    Return Value

    An NSDictionary object containing the keys and values from the query string.