NSString(KSTExtensions)

@interface NSString (KSTExtensions)

/**
 Creates and returns a reversed string from the receiver.
 
 @return The reversed string
 */
- (NSString *)KST_reversedString;

/**
 Create and return a string by removing all characters in the provided *set* from the receiver. This is distinct from stringByTrimmingCharactersInSet: which only removes characters at the beginning and end of the receiver.
 
 For example, [@"+1 (123) 456-7890" KST_stringByRemovingCharactersInSet:NSCharacterSet.decimalDigitCharacterSet.invertedSet] -> @"11234567890".
 
 @param set The set of characters to remove
 @return The string with characters removed
 */
- (NSString *)KST_stringByRemovingCharactersInSet:(NSCharacterSet *)set;

/**
 Create and return a string by removing characters in the provided *set* from the beginning of the receiver. This is similar to stringByTrimmingCharactersInSet:, but only removes characters from the beginning of the receiver.
 
 @param set The set of characters to remove
 @return The trimmed string
 */
- (NSString *)KST_stringByTrimmingLeadingCharactersInSet:(NSCharacterSet *)set;
/**
 Create and return a string by removing characters in the provided *set* from the end of the receiver. This is similar to stringByTrimmingCharactersInSet:, but only removes characters from the end of the receiver.
 
 @param set The set of characters to remove
 @return The trimmed string
 */
- (NSString *)KST_stringByTrimmingTrailingCharactersInSet:(NSCharacterSet *)set;

/**
 Returns the word within the receiver at the provided *range* or nil. Words are delimited by NSCharacterSet.whitespaceAndNewlineCharacterSet.
 
 @param range The range at which to search for a word
 @return The word or nil
 */
- (nullable NSString *)KST_wordAtRange:(NSRange)range;
/**
 Returns the word within the receiver at the provided *range* or nil. Words are delimited by NSCharacterSet.whitespaceAndNewlineCharacterSet. The range of the word within the receiver is returned by reference if *outRange* is non-Null.
 
 @param range The range at which to search for a word
 @param outRange The range of the word within the receiver
 @return The word or nil
 */
- (nullable NSString *)KST_wordAtRange:(NSRange)range outRange:(nullable NSRangePointer)outRange;

/**
 Creates and returns an NSString representing the SHA1 hash of the receiver.
 
 @return The NSString hash
 */
- (nullable NSString *)KST_SHA1String;
/**
 Creates and returns an NSString representing the SHA256 hash of the receiver.
 
 @return The NSString hash
 */
- (nullable NSString *)KST_SHA256String;
/**
 Creates and returns an NSString representing the SHA512 hash of the receiver.
 
 @return The NSString hash
 */
- (nullable NSString *)KST_SHA512String;

@end

Undocumented

  • Creates and returns a reversed string from the receiver.

    Declaration

    Objective-C

    - (nonnull NSString *)KST_reversedString;

    Return Value

    The reversed string

  • Create and return a string by removing all characters in the provided set from the receiver. This is distinct from stringByTrimmingCharactersInSet: which only removes characters at the beginning and end of the receiver.

    For example, [@“+1 (123) 456-7890” KST_stringByRemovingCharactersInSet:NSCharacterSet.decimalDigitCharacterSet.invertedSet] -> @“11234567890”.

    Declaration

    Objective-C

    - (nonnull NSString *)KST_stringByRemovingCharactersInSet:
        (nonnull NSCharacterSet *)set;

    Parameters

    set

    The set of characters to remove

    Return Value

    The string with characters removed

  • Create and return a string by removing characters in the provided set from the beginning of the receiver. This is similar to stringByTrimmingCharactersInSet:, but only removes characters from the beginning of the receiver.

    Declaration

    Objective-C

    - (nonnull NSString *)KST_stringByTrimmingLeadingCharactersInSet:
        (nonnull NSCharacterSet *)set;

    Parameters

    set

    The set of characters to remove

    Return Value

    The trimmed string

  • Create and return a string by removing characters in the provided set from the end of the receiver. This is similar to stringByTrimmingCharactersInSet:, but only removes characters from the end of the receiver.

    Declaration

    Objective-C

    - (nonnull NSString *)KST_stringByTrimmingTrailingCharactersInSet:
        (nonnull NSCharacterSet *)set;

    Parameters

    set

    The set of characters to remove

    Return Value

    The trimmed string

  • Returns the word within the receiver at the provided range or nil. Words are delimited by NSCharacterSet.whitespaceAndNewlineCharacterSet.

    Declaration

    Objective-C

    - (nullable NSString *)KST_wordAtRange:(NSRange)range;

    Parameters

    range

    The range at which to search for a word

    Return Value

    The word or nil

  • Returns the word within the receiver at the provided range or nil. Words are delimited by NSCharacterSet.whitespaceAndNewlineCharacterSet. The range of the word within the receiver is returned by reference if outRange is non-Null.

    Declaration

    Objective-C

    - (nullable NSString *)KST_wordAtRange:(NSRange)range
                                  outRange:(nullable NSRangePointer)outRange;

    Parameters

    range

    The range at which to search for a word

    outRange

    The range of the word within the receiver

    Return Value

    The word or nil

  • Creates and returns an NSString representing the SHA1 hash of the receiver.

    Declaration

    Objective-C

    - (nullable NSString *)KST_SHA1String;

    Return Value

    The NSString hash

  • Creates and returns an NSString representing the SHA256 hash of the receiver.

    Declaration

    Objective-C

    - (nullable NSString *)KST_SHA256String;

    Return Value

    The NSString hash

  • Creates and returns an NSString representing the SHA512 hash of the receiver.

    Declaration

    Objective-C

    - (nullable NSString *)KST_SHA512String;

    Return Value

    The NSString hash