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.

    @returns A string encoded for an HTTP query parameter.

    Declaration

    Objective-C

    - (nonnull NSString *)hb_stringByEncodingQueryPercentEscapes;

    Swift

    func hb_stringByEncodingQueryPercentEscapes() -> String
  • Returns a string decoded from an HTTP query parameter.

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

    @returns A string decoded from an HTTP query parameter.

    Declaration

    Objective-C

    - (nonnull NSString *)hb_stringByDecodingQueryPercentEscapes;

    Swift

    func hb_stringByDecodingQueryPercentEscapes() -> String
  • 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.

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

    Declaration

    Objective-C

    - (nonnull NSDictionary *)hb_queryStringComponents;

    Swift

    func hb_queryStringComponents() -> [AnyHashable : Any]