Categories

The following categories are available globally.

  • Adds support for KSTDeepCopying to NSArray.

    See more

    Declaration

    Objective-C

    @interface NSArray <__covariant ObjectType>(KSTDeepCopyingExtensions)
  • Adds support for KSTDeepCopying to NSSet.

    See more

    Declaration

    Objective-C

    @interface NSSet <__covariant ObjectType>(KSTDeepCopyingExtensions)
  • Adds support for KSTDeepCopying to NSDictionary.

    See more

    Declaration

    Objective-C

    @interface NSDictionary <__covariant KeyType,
                             __covariant ObjectType>(KSTDeepCopyingExtensions)
  • Adds support for KSTDeepMutableCopying to NSArray.

    See more

    Declaration

    Objective-C

    @interface NSArray <__covariant ObjectType>(KSTDeepMutableCopyingExtensions)
  • Adds support for KSTDeepMutableCopying to NSSet.

    See more

    Declaration

    Objective-C

    @interface NSSet <__covariant ObjectType>(KSTDeepMutableCopyingExtensions)
  • Adds support for KSTDeepMutableCopying to NSDictionary.

    See more

    Declaration

    Objective-C

    @interface NSDictionary <__covariant KeyType, __covariant ObjectType>(
        KSTDeepMutableCopyingExtensions)
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSCharacterSet (KSTPhoneNumberFormatterExtensions)
    
    /**
     The complete set of characters KSTPhoneNumberFormatter allows in formatted string representations of phone numbers.
     */
    @property (class,readonly,nonatomic) NSCharacterSet *KST_phoneNumberFormattedCharacterSet;
    /**
     The complete set of characters that affect the routing of the phone number. This is defined as @"0123456789" + @"abcdABCD+*#".
     */
    @property (class,readonly,nonatomic) NSCharacterSet *KST_phoneNumberRoutingCharacterSet;
    /**
     The decimal digits allowed in phone numbers. This is defined as @"0123456789".
     */
    @property (class,readonly,nonatomic) NSCharacterSet *KST_phoneNumberDecimalCharacterSet;
    
    @end
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSArray<__covariant ObjectType> (KSTExtensions)
    
    /**
     Creates and returns an NSArray with the receiver's objects in reverse order.
     
     @return The reversed array
     */
    - (NSArray<ObjectType> *)KST_reversedArray;
    
    /**
     Create and return an array by appending *object* onto the receiver.
     
     @param object The object to append
     @return The new array
     */
    - (NSArray<ObjectType> *)KST_arrayByAppendingObject:(ObjectType)object;
    /**
     Creates and returns an array by appending the objects from array onto the receiver.
     
     @param array The objects to append
     @return The new array
     */
    - (NSArray<ObjectType> *)KST_arrayByAppendingArray:(NSArray<ObjectType> *)array;
    /**
     Create and return an array by prepending *object* onto the receiver.
     
     @param object The object to prepend
     @return The new array
     */
    - (NSArray<ObjectType> *)KST_arrayByPrependingObject:(ObjectType)object;
    /**
     Creates and returns an array by prepending the objects from array onto the receiver.
     
     @param array The objects to prepend
     @return The new array
     */
    - (NSArray<ObjectType> *)KST_arrayByPrependingArray:(NSArray<ObjectType> *)array;
    
    /**
     Create and return an array by removing the objects in the provided *array*.
     
     @param array The objects to remove
     @return The new array
     */
    - (NSArray<ObjectType> *)KST_arrayByRemovingArray:(NSArray<ObjectType> *)array;
    
    /**
     Creates and returns an NSArray with the receiver's objects.
     
     @return The NSSet created from the receiver
     */
    - (NSSet<ObjectType> *)KST_set;
    /**
     Creates and returns an NSMutableSet with the receiver's objects.
     
     @return The NSMutableSet created from the receiver
     */
    - (NSMutableSet<ObjectType> *)KST_mutableSet;
    
    /**
     Returns an NSOrderedSet with the receiver's objects.
     
     @return The NSOrderedSet
     */
    - (NSOrderedSet<ObjectType> *)KST_orderedSet;
    /**
     Returns an NSMutableOrderedSet with the receiver's objects.
     
     @return The NSMutableOrderedSet
     */
    - (NSMutableOrderedSet<ObjectType> *)KST_mutableOrderedSet;
    
    /**
     Creates and returns a shuffled copy of the receiver.
     
     @return The shuffled NSArray
     */
    - (NSArray<ObjectType> *)KST_shuffledArray;
    
    /**
     Returns the object at a random index in the receiver.
     
     @return The random object
     */
    - (nullable ObjectType)KST_objectAtRandomIndex;
    
    /**
     Returns the object at the provided *index* if *index* is within the receiver's bounds, otherwise returns nil.
     
     @param index The array index
     @return The object or nil
     */
    - (nullable ObjectType)KST_safeObjectAtIndex:(NSUInteger)index;
    
    @end
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSBundle (KSTExtensions)
    
    /**
     Returns the current bundle based on the calling context. For example, if you call this property within a framework, it will return the framework bundle. If you call this property in the main app, it will return the main bundle.
     */
    @property (class,readonly,nonatomic) NSBundle *KST_currentBundle;
    
    /**
     Returns the bundle identifier. For example, "com.mycompany.app".
     
     @return The bundle identifier
     */
    - (NSString *)KST_bundleIdentifier;
    /**
     Returns the bundle display name. For example, "App". This value is localized.
     
     @return The bundle display name
     */
    - (nullable NSString *)KST_bundleDisplayName;
    /**
     Returns the bundle executable. For example, "App". This value is not localized.
     
     @return The bundle executable
     */
    - (NSString *)KST_bundleExecutable;
    /**
     Returns the bundle short version string. For example, "1.0.0".
     
     @return The bundle short version string
     */
    - (NSString *)KST_bundleShortVersionString;
    /**
     Returns the bundle version. For example, "1".
     
     @return The bundle version
     */
    - (NSString *)KST_bundleVersion;
    
    @end
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSCharacterSet (KSTExtensions)
    
    /**
     Returns an array containing every string in the receiver.
     */
    @property (readonly,copy,nonatomic) NSArray<NSString *> *KST_allStrings;
    
    @end
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSData (KSTExtensions)
    
    /**
     Creates and returns an NSString representing the SHA1 hash of the receiver's bytes.
     
     @return The NSString hash
     */
    - (nullable NSString *)KST_SHA1String;
    /**
     Creates and returns an NSString representing the SHA256 hash of the receiver's bytes.
     
     @return The NSString hash
     */
    - (nullable NSString *)KST_SHA256String;
    /**
     Creates and returns an NSString representing the SHA512 hash of the receiver's bytes.
     
     @return The NSString hash
     */
    - (nullable NSString *)KST_SHA512String;
    
    @end
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSDate (KSTExtensions)
    
    /**
     Returns the day component from a NSDateComponents created from the receiver.
     
     @return The day of the receiver
     */
    - (NSInteger)KST_day;
    /**
     Returns the month component from a NSDateComponents created from the receiver.
     
     @return The month of the receiver
     */
    - (NSInteger)KST_month;
    /**
     Returns the year component from a NSDateComponents created from the receiver.
     
     @return The year of the receiver
     */
    - (NSInteger)KST_year;
    
    /**
     Returns a NSDate representing the beginning of the day, which is 12:00:00 AM.
     
     @return The beginning of the day date
     */
    - (NSDate *)KST_beginningOfDay;
    /**
     Returns a NSDate representing the end of the day, which is 11:59:59 PM.
     
     @return The end of the day date
     */
    - (NSDate *)KST_endOfDay;
    
    @end
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSDictionary<__covariant KeyType, __covariant ObjectType> (KSTExtensions)
    
    /**
     Returns a new dictionary by adding the entries from *dictionary* to the receiver.
     
     @param dictionary The dictionary whose entries should be added
     @return The new dictionary
     */
    - (NSDictionary<KeyType, ObjectType> *)KST_dictionaryByAddingDictionaryEntries:(NSDictionary<KeyType, ObjectType> *)dictionary;
    
    @end
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSError (KSTExtensions)
    
    /**
     Returns the default alert title.
     */
    @property (class,readonly,nonatomic) NSString *KST_defaultAlertTitle;
    /**
     Returns the default alert message.
     */
    @property (class,readonly,nonatomic) NSString *KST_defaultAlertMessage;
    
    /**
     Returns the value for the KSTErrorAlertTitleKey key in the receiver's userInfo dictionary if non-nil, otherwise returns KST_defaultAlertTitle.
     
     @return The alert title
     */
    @property (readonly,nonatomic) NSString *KST_alertTitle;
    /**
     Returns the value for the KSTErrorAlertMessageKey key in the receiver's userInfo dictionary if non-nil, then the value for the NSLocalizedDescriptionKey key, then KST_defaultAlertMessage.
     
     @return The alert message
     */
    @property (readonly,nonatomic) NSString *KST_alertMessage;
    
    @end
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSFileManager (KSTExtensions)
    
    /**
     Returns the NSURL instance representing the application support directory, creating the directory if it does not exist. On macOS, appends the bundle executable name to the returned URL (e.g. <application_support>/<bundle_executable>).
     
     @return The application support NSURL instance
     */
    - (NSURL *)KST_applicationSupportDirectoryURL;
    /**
     Returns the NSURL instance representing the caches directory. On macOS, appends the bundle identifier to the returned URL (e.g. <caches>/<bundle_identifier>) and creates the directory if it does not already exist. On iOS, the base caches directory will always exist.
     
     @return The caches NSURL instance
     */
    - (NSURL *)KST_cachesDirectoryURL;
    /**
     Returns the NSURL instance representing the document directory.
     
     @return The document NSURL instance
     */
    - (NSURL *)KST_documentDirectoryURL;
    
    @end
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSHTTPURLResponse (KSTExtensions)
    
    /**
     Returns the localized description returned by `[NSHTTPURLResponse localizedStringForStatusCode]`.
     
     @return The localized description
     */
    - (NSString *)KST_localizedStatusCodeString;
    
    @end
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSMutableArray<ObjectType> (KSTExtensions)
    
    /**
     If self.count > 0, removes the first object in the receiver; otherwise does nothing.
     */
    - (void)KST_removeFirstObject;
    
    /**
     Reverses the objects of the receiver. This is distinct from KST_reversedArray, which returns a new array.
     */
    - (void)KST_reverse;
    
    /**
     Adds *object* to the end of the receiver. Simply calls addObject:.
     
     @param object The object to add
     */
    - (void)KST_appendObject:(ObjectType)object;
    /**
     Adds the objects in *array* to the end of the receiver. Simply calls addObjectsFromArray:.
     
     @param array The objects to add
     */
    - (void)KST_appendArray:(NSArray<ObjectType> *)array;
    /**
     Adds the *object* to the beginning of the receiver (i.e. index 0).
     
     @param object The object to add
     */
    - (void)KST_prependObject:(ObjectType)object;
    /**
     Adds the objects in *array* to the beginning of the receiver (i.e. starting at index 0).
     
     @param array The objects to add
     */
    - (void)KST_prependArray:(NSArray<ObjectType> *)array;
    
    /**
     Inserts _object_ at index 0 of the receiver.
     
     @param object The object to insert
     */
    - (void)KST_push:(ObjectType)object;
    /**
     Removes the first object of the receiver and returns it.
     
     @return The first object of the receiver or nil
     */
    - (nullable ObjectType)KST_pop;
    
    /**
     Shuffles the receiver. See http://stackoverflow.com/questions/56648/whats-the-best-way-to-shuffle-an-nsmutablearray for implementation reference.
     */
    - (void)KST_shuffle;
    
    @end
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSObject (KSTExtensions)
    
    /**
     Set and get an arbitrary object associated with the receiver. Convenience property to associate additional objects with the receiver.
     */
    @property (strong,nonatomic,nullable) id KST_representedObject;
    
    /**
     Used in place of a respondsToSelector: check before calling a method that returns void. For example:
     
     MyClass foo = ...;
     
     if ([foo respondsToSelector:@selector(bar)]) {
        [foo bar];
     }
     
     would become:
     
     MyClass foo = ...;
     
     [[foo KST_performIfResponds] bar];
     */
    - (instancetype)KST_performIfResponds;
    /**
     Used in place of a respondsToSelector: check before calling a method that returns an id value. For example:
     
     MyClass foo = ...;
     
     if ([foo respondsToSelector:@selector(baz)]) {
        id retval = [foo baz];
     }
     
     would become:
     
     MyClass foo = ...;
     id retval = [[foo KST_performOrReturn:nil] baz];
     
     @param value The default return value that should be used if the receiver does not respond to the method
     @return Either the return value from the receiver or the default return value
     */
    - (instancetype)KST_performOrReturn:(nullable id)value;
    /**
     Used in place of a respondsToSelector: check before calling a method that returns a non-object value (struct, primitive, etc). For example:
     
     MyClass foo = ...;
     
     if ([foo respondsToSelector:@selector(boop)]) {
        NSUInteger retval = [foo boop];
     }
     
     would become:
     
     MyClass foo = ...;
     NSUInteger retval = [[foo KST_performOrReturnValue:@0] boop];
     
     @param value The default value that should be used if the receiver does not respond to the method
     @return Either the return value from the receiver or the default return value
     */
    - (instancetype)KST_performOrReturnValue:(nullable NSValue *)value;
    
    /**
     A method for mapping the properties of an NSObject and returning the contents as an NSDictionary
     
     @param transformer An NSValueTransformer instance for converting the property names/dictionary keys
     @param dateFormatter An NSDateFormatter to format NSDate properties
     @param properties A set of property names to be excluded from the return dictionary
     @return The dictionary representaiton of the object
     */
    - (nullable NSDictionary *)KST_dictionaryWithValueTransformer:(nullable NSValueTransformer *)transformer dateFormatter:(nullable NSDateFormatter *)dateFormatter excludingProperties:(NSSet <NSString *> *)properties;
    
    /**
     A method for populating the properties of an NSObject with a JSON dictionary
     
     @param dictionary The dictionary representation of the object to populate
     @param dateFormatter An NSDateFormatter to format NSDate properties
     @param transformer An NSValueTrasformer for converting JSON keys to property names
     */
    - (void)KST_setPropertiesWithJSONDictionary:(NSDictionary <NSString *, id> *)dictionary dateFormatter:(nullable NSDateFormatter *)dateFormatter valueTransformer:(nullable NSValueTransformer *)transformer;
    
    @end
  • Undocumented

    See more

    Declaration

    Objective-C

    @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

    See more

    Declaration

    Objective-C

    @interface NSURL (KSTExtensions)
    
    /**
     Returns the value associated with the NSURLCreationDateKey key.
     
     @return The associated creation date
     */
    @property (readonly,nonatomic,nullable) NSDate *KST_creationDate;
    /**
     Returns the value associated with the NSURLContentModificationDateKey key.
     
     @return The associated content modification date
     */
    @property (readonly,nonatomic,nullable) NSDate *KST_contentModificationDate;
    /**
     Returns the value associated with the NSURLIsDirectoryKey key.
     
     @return The associated isDirectory value
     */
    @property (readonly,nonatomic) BOOL KST_isDirectory;
    /**
     Returns the value associated with the NSURLTypeIdentifierKey key.
     
     @return The associated type identifier
     */
    @property (readonly,nonatomic,nullable) NSString *KST_typeIdentifier;
    
    /**
     Creates and returns a dictionary with query keys mapping to query values.
     
     @return The query dictionary
     */
    - (nullable NSDictionary *)KST_queryDictionary;
    
    /**
     Create and return an NSURL with *baseString* and optional query *parameters*.
     
     @param baseString The base string of the NSURL
     @param parameters Optional parameters dictionary
     @return The NSURL created from *baseString* and *parameters*
     */
    + (nullable NSURL *)KST_URLWithBaseString:(NSString *)baseString parameters:(nullable NSDictionary *)parameters;
    
    @end
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSURLRequest (KSTExtensions)
    
    /**
     Returns `[self KST_URLRequestWithURL:URL HTTPMethod:HTTPMethod HTTPHeaderFields:nil]`.
     
     @param URL The URL for the request
     @param HTTPMethod The HTTP method for the request
     @return The request
     */
    + (NSURLRequest *)KST_URLRequestWithURL:(NSURL *)URL HTTPMethod:(KSTHTTPMethod)HTTPMethod;
    /**
     Creates and returns an `NSURLRequest` instance with the provided *URL*, *HTTPMethod* and *HTTPHeaderFields*.
     
     @param URL The URL for the request
     @param HTTPMethod The HTTP method for the request
     @param HTTPHeaderFields The HTTP header fields for the request
     @return The request
     */
    + (NSURLRequest *)KST_URLRequestWithURL:(NSURL *)URL HTTPMethod:(KSTHTTPMethod)HTTPMethod HTTPHeaderFields:(nullable NSDictionary<KSTHTTPHeaderField, NSString *> *)HTTPHeaderFields;
    
    @end