TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Feb 2017 |
Maintained by Nicolas Goutaland.
Objective-C categories, used for years in my projects.
Some categories were not written by me, is so I've added the original source in header comment, but I may have missed some.
If so, do not hesitate to tell me, I will update headers to add the original source.
Simply call method you want to use with appropriate parameters.
CocoaPods: pod 'GONCategories'
Manual: Copy the Classes folder in your project
Import wanted headers in your project. .pch is a good place ;)
You can also import GON_Categories_All.h to add all categories in your project.
GON_Categories_All.h : Import all categories
GON_CoreData_All.h : Import all core data related categories
GON_FoundationExtensions_All.h : Import all foundation related categories
GON_UIKitExtensions_All.h : Import all UIKit related categories
GON_StoreKitExtensions_All.h : Import all StoreKit related categories
/* Fetch one object using given key and value. Usefull to fetch objects on their uid key
* /!\ Warning, errors are ignored /!\
*/
- (id)fetchObject:(NSString *)entityName usingValue:(id)value forKey:(NSString *)key returningAsFault:(BOOL)fault;
/* Fetch one object using given predicate
* /!\ Warning, errors are ignored /!\
*/
- (id)fetchObject:(NSString *)entityName usingPredicate:(NSPredicate *)predicate returningAsFault:(BOOL)fault;
/* Count all objects for given entity.
* /!\ Warning, errors are ignored /!\
*/
- (NSInteger)countObjects:(NSString *)entityName;
/* Count all objects using given predicate
* /!\ Warning, errors are ignored /!\
*/
- (NSInteger)countObjects:(NSString *)entityName usingPredicate:(NSPredicate *)predicate;
/* Fetch all objects for given entity.
* /!\ Warning, errors are ignored /!\
*/
- (NSArray *)fetchObjects:(NSString *)entityName returningAsFault:(BOOL)fault;
/* Fetch all objects using given predicate
* /!\ Warning, errors are ignored /!\
*/
- (NSArray *)fetchObjects:(NSString *)entityName usingPredicate:(NSPredicate *)predicate returningAsFault:(BOOL)fault;
/* Fetch all objects for given entity and sort them.
* /!\ Warning, errors are ignored /!\
*/
- (NSArray *)fetchObjects:(NSString *)entityName usingSortDescriptors:(NSArray *)sortDescriptors returningAsFault:(BOOL)fault;
/* Fetch all objects for given entity, using predicate and sort them.
* /!\ Warning, errors are ignored /!\
*/
- (NSArray *)fetchObjects:(NSString *)entityName usingPredicate:(NSPredicate *)predicate usingSortDescriptors:(NSArray *)sortDescriptors returningAsFault:(BOOL)fault;
/* Create fetch request to fetch one object using given key and value. Usefull to fetch objects on their uid key */
- (NSFetchRequest*)fetchRequestForEntityObject:(NSString*)entityName usingValue:(id)value forKey:(NSString*)key returningAsFault:(BOOL)fault;
/* Create fetch request to fetch one object using given predicate
*/
- (NSFetchRequest*)fetchRequestForEntityObject:(NSString*)entityName usingPredicate:(NSPredicate*)predicate returningAsFault:(BOOL)fault;
/* Create fetch request to fetch all objects for given entity.
*/
- (NSFetchRequest*)fetchRequestForEntityObjects:(NSString*)entityName returningAsFault:(BOOL)fault;
/* Create fetch request to fetch all objects using given predicate
*/
- (NSFetchRequest*)fetchRequestForEntityObjects:(NSString*)entityName usingPredicate:(NSPredicate*)predicate returningAsFault:(BOOL)fault;
/* Create fetch request to fetch all objects for given entity and sort them.
*/
- (NSFetchRequest*)fetchRequestForEntityObjects:(NSString*)entityName usingSortDescriptors:(NSArray*)sortDescriptors returningAsFault:(BOOL)fault;
/* Create fetch request to fetch all objects for given entity, using predicate and sort them.
*/
- (NSFetchRequest*)fetchRequestForEntityObjects:(NSString*)entityName usingPredicate:(NSPredicate*)predicate usingSortDescriptors:(NSArray*)sortDescriptors returningAsFault:(BOOL)fault;
/* Delete all given objects*/
- (void)deleteObjects:(id <NSFastEnumeration>)objects;
/* Must be implemented in subclasses to provide an array of NSSortDescriptors used in fetch request */
+ (NSArray *)sortDescriptors;
@interface NSManagedObject (PropertyExtraction)
/* Return an array of dictionaries containing values for asked properties names.
* Request is executed on class entity
*/
+ (NSArray *)valuesForProperties:(NSArray *)propertiesNames usingPredicate:(NSPredicate *)predicate managedObjectContext:(NSManagedObjectContext *)context;
/* Return an array of values for asked property name
* Request is executed on class entity */
+ (NSArray *)valuesForProperty:(NSString *)propertyName usingPredicate:(NSPredicate *)predicate managedObjectContext:(NSManagedObjectContext *)context;
/* Return NSPropertyDescription for current entity, describing given attribute name */
+ (NSPropertyDescription*)propertyDescriptionForAttribute:(NSString*)attributeName inManagedObjectContext:(NSManagedObjectContext*)moc;
/* Return an array of NSPropertyDescription for current entity, describing given attributes name */
+ (NSArray *)propertiesDescriptionForAttributes:(NSArray*)attributesName inManagedObjectContext:(NSManagedObjectContext*)moc;
/* Return NSEntityDescription for current entity */
+ (NSEntityDescription*)entityDescription:(NSManagedObjectContext*)moc;
/* Create fetch request to fetch one object using given key and value. Usefull to fetch objects on their uid key */
+ (NSFetchRequest*)fetchRequestUsingValue:(id)value forKey:(NSString*)key returningAsFault:(BOOL)fault forManagedObjectContext:(NSManagedObjectContext*)moc;
/* Create fetch request to fetch one object using given predicate
*/
+ (NSFetchRequest*)fetchRequestUsingPredicate:(NSPredicate*)predicate returningAsFault:(BOOL)fault forManagedObjectContext:(NSManagedObjectContext*)moc;
/* Create fetch request to fetch all objects for given entity.
*/
+ (NSFetchRequest*)fetchRequestForAllEntitiesReturningAsFault:(BOOL)fault forManagedObjectContext:(NSManagedObjectContext*)moc;
/* Create fetch request to fetch all objects using given predicate
*/
+ (NSFetchRequest*)fetchRequestForAllEntitiesUsingPredicate:(NSPredicate*)predicate returningAsFault:(BOOL)fault forManagedObjectContext:(NSManagedObjectContext*)moc;
/* Create fetch request to fetch all objects for given entity and sort them.
*/
+ (NSFetchRequest*)fetchRequestForAllEntitiesUsingSortDescriptors:(NSArray*)sortDescriptors returningAsFault:(BOOL)fault forManagedObjectContext:(NSManagedObjectContext*)moc;
/* Create fetch request to fetch all objects for given entity, using predicate and sort them.
*/
+ (NSFetchRequest*)fetchRequestForAllEntitiesUsingPredicate:(NSPredicate*)predicate usingSortDescriptors:(NSArray*)sortDescriptors returningAsFault:(BOOL)fault forManagedObjectContext:(NSManagedObjectContext*)moc;
/* Create fetch request to fetch all objects for given entity. Class default sort descriptors are set.
* You have to add a + (NSArray *)sortDescriptors method in your entity class to provide your own sort descriptors
*/
+ (NSFetchRequest*)fetchRequestForAllSortedEntitiesReturningAsFault:(BOOL)fault forManagedObjectContext:(NSManagedObjectContext*)moc;
/* Create fetch request to fetch all objects using given predicate. Class default sort descriptors are set.
* You have to add a + (NSArray *)sortDescriptors method in your entity class to provide your own sort descriptors
*/
+ (NSFetchRequest*)fetchRequestForAllSortedEntitiesUsingPredicate:(NSPredicate*)predicate returningAsFault:(BOOL)fault forManagedObjectContext:(NSManagedObjectContext*)moc;
/* Return a configured FetchedResultsController */
+ (NSFetchedResultsController*)fetchedResultsControllerForFetchRequest:(NSFetchRequest*)fetchRequest delegate:(id <NSFetchedResultsControllerDelegate>)delegate usingManagedObjectContext:(NSManagedObjectContext*)moc;
/* Return a configured FetchedResultsController using given cache */
+ (NSFetchedResultsController*)fetchedResultsControllerForFetchRequest:(NSFetchRequest*)fetchRequest cache:(NSString*)cache delegate:(id <NSFetchedResultsControllerDelegate>)delegate usingManagedObjectContext:(NSManagedObjectContext*)moc;
/* Return a configured FetchedResultsController using given section name */
+ (NSFetchedResultsController*)fetchedResultsControllerForFetchRequest:(NSFetchRequest*)fetchRequest sectionName:(NSString*)sectionName delegate:(id <NSFetchedResultsControllerDelegate>)delegate usingManagedObjectContext:(NSManagedObjectContext*)moc;
/* Return a configured FetchedResultsController using given cache and section name */
+ (NSFetchedResultsController*)fetchedResultsControllerForFetchRequest:(NSFetchRequest*)fetchRequest cache:(NSString*)cache sectionName:(NSString*)sectionName delegate:(id <NSFetchedResultsControllerDelegate>)delegate usingManagedObjectContext:(NSManagedObjectContext*)moc;
/* Return a configured FetchedResultsController using a generated cache name */
+ (NSFetchedResultsController*)fetchedResultsControllerCachedForFetchRequest:(NSFetchRequest*)fetchRequest delegate:(id <NSFetchedResultsControllerDelegate>)delegate usingManagedObjectContext:(NSManagedObjectContext*)moc;
/* Return a configured FetchedResultsController using a generated cache name and given section name */
+ (NSFetchedResultsController*)fetchedResultsControllerCachedForFetchRequest:(NSFetchRequest*)fetchRequest sectionName:(NSString*)sectionName delegate:(id <NSFetchedResultsControllerDelegate>)delegate usingManagedObjectContext:(NSManagedObjectContext*)moc;
``
##Foundation
###GON_NSArray+Utils
/* Return a shuffled copy of this array */
/* Return a reversed version of array */
/* Convert given array to a dicitonary using given valueForKey field as key in dictionary.
/* Return an array built calling valueForKey:key on each object.
/* Return a deep mutable copy */
@property (nonatomic, readonly) NSRange range; // Return the range of the array (0, count)
###GON_NSArray+SortedArray
/* Retrieve object insertion index, assuming the array is sorted, using given function */
/* Retrieve object insertion index, assuming the array is sorted, using given selector */
/* Retrieve object insertion index, assuming the array is sorted, using given sort descriptors */
/* Retrieve object insertion index, assuming the array is sorted, using given block */
###GON_NSData+Base64
/* Return a base 64 encoded string from NSData */
###GON_NSData+String
/* Return data as an hexa string */
/* Return data as an UFT8 encoded string */
###GON_NSDate+Utils
/* Yesterday constructor */
/* Today constructor */
/* Tomorrow constructor */
/* Tells is date is Yesterday */
/* Tells is date is Today */
/* Tells is date is Tomorrow */
/* Create a new date by adding given days */
/* Build yesterday date from date, keeping hour */
/* Build tomorrow date from date, keeping hour */
/* Build an return a date, stripping hour informations */
/* Convert local time date to gmt one */
/* Convert date to local time one, assuming date is a gmt one */
/* Compare both date, ignoring time informations */
###GON_NSDictionary+Utils
/* Same as objectForKey:, but returning nil if object is [NSNull null] */
/* Same as objectForKeyOrNil:, but return defaultValue instead of nil if no value found */
/* Same as objectForKey:, but return defaultValue instead of nil if no value found */
/* Assume dictionary values are NSSet object, so return anyObject on one associated to key */
/* Return inverted dictionary, using keys as value and vice versa.
/* Check if dictionary has given key */
/* Return a deep mutable copy */
###GON_NSFileManager+Utils
/* Return size for item at given path.
/* Check if given file is a directory or not */
###GON_NSHTTPURLResponse+Error
/* Generate an NSError object based on url response
@property (nonatomic, readonly) BOOL hasError; // Tells if status code match an error
###GON_NSIndexPath+Offset
/* Compute previous row indexpath */
/* Compute next row indexpath */
/* Compute previous item indexpath */
/* Compute next item indexpath */
/* Compute next section indexpath */
/* Compute previous section indexpath */
###GON_NSMutableArray+SortedArray
/* Insert object into array, assuming the array is sorted, using given function */
/* Insert object into array, assuming the array is sorted, using given selector */
/* Insert object into array, assuming the array is sorted, using given sort descriptors */
/* Retrieve object insertion index, assuming the array is sorted, using given block */
###GON_NSMutableArray+Utils
/* Insert an object at the first position in the array */
/* Remove first object from array. Same as [self removeObjectAtIndex:0]. */
/* Shuffle array */
###GON_NSMutableDictionary+Set
/* Same as setObject:forKey:, but adding values in a NSMutableSet */
/* Same as setObject:forKey:, but unions all values in a NSMutableSet */
/* Same as removeObjectForKey:, but removing value from the created set. If set is empty after operation, it will be removed. */
###GON_NSMutableDictionary+Array
/* Same as setObject:forKey:, but adding values in a NSMutableArray */
/* Same as setObject:forKey:, but unions all values in a NSMutableArray */
/* Same as removeObjectForKey:, but removing value from the created array. If array is empty after operation, it will be removed. */
###GON_NSMutableDictionary+SortedArray
/* Same as setObject:forKey:, but adding values in a sorted NSMutableArray using given function */
/* Same as setObject:forKey:, but adding values in a sorted NSMutableArray using given selector */
/* Same as setObject:forKey:, but adding values in a sorted NSMutableArray using given descriptors */
/* Same as setObject:forKey:, but adding values in a sorted NSMutableArray using given block */
###GON_NSMutableString+Utils
/* Trim string
/* Uppercase first letter of string
/* Lowercase first letter of string
/* Remove all diacritics markings
/* Add non breaking space characters to string :
/* Replace all HTML entities by UTF-8 character
/* Add HTML entities to string.
###GON_NSNotification+Constructors
/* Build a notification with given name and given sender, building user info with anObject and key */
###GON_NSNotificationCenter+MainThread
/* Post given notifcation on main thread */
/* Post given notifcation name on main thread */
/* Post given notifcation name on main thread with user info */
/* Post given notifcation on main thread, allowing to wait until done */
/* Post given notifcation name on main thread, allowing to wait until done */
/* Post given notifcation name on main thread with user info, allowing to wait until done */
###GON_NSObject+Block
/* Perfom a block on main queue, no delay. Dispatch is synchrone */
/* Perfom a block on main queue, no delay. Dispatch is asynchrone */
/* Perform a block on main queue, after delay */
/* Perfom a block on background queue, no delay. Dispatch is asynchrone */
/* Perfom a block on background queue, no delay. Dispatch is synchrone */
/* Perform a block on given queue, after delay */
###GON_NSNumber+Compare
/* Return bigger number between self and other number. Like MAX, for NSNumber.
/* Return smallest number between self and other number. Like MIN, for NSNumber
###GON_NSString+Base64
/* Return data from string, assuming that's a base 64 encoded one */
###GON_NSString+Crypto
/* Return hashed SHA256 string */
/* Return hashed SHA256 base on string converted to utf16 */
/* Return hashed MD5 string */
/* Return hashed MD5 base on string converted to utf16 */
###GON_NSString+SQL
/* Return cleaned version of SQL value by escaping ' characters */
###GON_NSString+Utils
/* Return a new string, initialized with a generated uuid */
/* Return a new string, by appending given suffix to it, assuming its a path.
/* Return YES if string contains given string */
/* Return YES if string begins with given string */
/* Return YES if string ends with given string */
/* Return trimmed string */
/* Return a string adding non breaking space characters :
/* Return same string with uppercased first letter */
/* Return same string with lowercased first letter */
/* Return same string removing all diacritics markings */
/* Return range of string */
/* Return an URL encoded string */
/* Return a string, with all HTML entities replaced by UTF-8 character */
/* Return a string, adding HTML entities when needed */
###GON_NSURL+Utils
/* Return query parameters */
###GON_NSURL+Split
/* Compute an array of url based on baseURL, with concatened values
/* Compute urls based on baseURL, with concatened values.
##UIKit
###GON_UIColor+Utils
/* Return best matching foreground color according to current color.
###GON_UIControl+Utils
/* Remove all targets for given control events */
/* Remove all targets */
###GON_UIDevice+Information
@property (nonatomic, readonly) NSString *platform; @property (nonatomic, readonly) NSUInteger coresCount;
###GON_UIImage+Colors
/* Return a grayscale version of image. Return nil if an error occurred */
###GON_UIImage+Utils
/* Return size of an image at given path, without loading it into memory */
/* Return size of an image at given url, without loading it into memory */
/* Return NSData PNG image representation */
/* Return NSData JPG image representation */
###GON_UILabel+AttributedFitting
/* Update label text and allow to fit its frame in order to display all text on multiples lines, keeping current width.
/* Update label frame in order to display all text on multiples lines, keeping current width.
/* Update label text and allows to fit its frame in order to display all text on a single lines.
/* Update label text and allows to fit its frame in order to display as many text as possible constrained by given height.
/* Update label text and allows to fit its frame in order to display as many text as possible constrained by given width.
/* Update label text and allows to fit its frame in order to display as many text as possible constrained by given height.
/* Update label text and allows to fit its frame in order to display as many text as possible constrained by given width.
/* Update label frame in order to display all text on a single line.
/* Update label frame in order to display as many text as possible on a single line, constrained by given width
/* Update label frame in order to display as many text as possible on multiple lines, constrained by given height
###GON_UILabel+Fitting
/* Update label text and allow to fit its frame in order to display all text on multiples lines, keeping current width.
/* Update label frame in order to display all text on multiples lines, keeping current width.
/* Update label text and allows to fit its frame in order to display all text on a single lines.
/* Update label text and allows to fit its frame in order to display as many text as possible constrained by given height.
/* Update label text and allows to fit its frame in order to display as many text as possible constrained by given width.
/* Update label text and allows to fit its frame in order to display as many text as possible constrained by given height.
/* Update label text and allows to fit its frame in order to display as many text as possible constrained by given width.
/* Update label frame in order to display all text on a single line.
/* Update label frame in order to display as many text as possible on a single line, constrained by given width
/* Update label frame in order to display as many text as possible on multiple lines, constrained by given height
###GON_UINavigationController+Utils
/* Pop current view controller, animated. Same as popViewControllerAnimated:YES */
/* Pop to root view controller, animated. Same as popToRootViewControllerAnimated:YES */
/* Pop current view controller, without animation. Same as popViewControllerAnimated:NO */
/* Pop to root view controller, without animation. Same as popToRootViewControllerAnimated:NO */
###GON_UITableView+Reload
/* Reload visible rows with given row animation.
/* Reload row at given index path with an animation
###GON_UITableView+Cells
/* Insert one row at given index path */
/* Delete one row from given index path */
###GON_UIView+Bounds
/* Update view bounds origin X */
/* Update view bounds origin Y */
/* Update view bounds size width */
/* Update view bounds size height */
/* Add incX to view bounds origin X */
/* Add incY to view bounds origin X */
/* Add incWidth to view bounds origin X */
/* Add incHeight to view bounds origin X */
###GON_UIView+Fitting
/* Update view frame, centering it vertically and horizontally compared to its superview */
/* Update view frame, centering it horizontally compared to its superview */
/* Update view frame, centering it vertically compared to its superview */
/* Change view frame to fill its superview frame : */
/* Change view frame to fill its superview width : */
/* Change view frame to fill its superview height : */
###GON_UIView+Frame
/* Update view frame origin */
/* Update view frame size */
/* Update view frame origin X */
/* Update view frame origin Y */
/* Update view center X */
/* Update view center Y */
/* Update view frame size width */
/* Update view frame size height */
/* Add incX to view frame origin X */
/* Add incY to view frame origin X */
/* Add incWidth to view frame origin X */
/* Add incHeight to view frame origin X */
###GON_UIView+Utils
/* Return an image created from view */
###GON_UIViewController+Utils
/* Dismiss current modal view controller, animated. Same as dismissViewControllerAnimated:YES completion:nil */
/* Dismiss current modal view controller, without animation. Same as dismissViewControllerAnimated:NO completion:nil */
###GON_UIScrollView+Fitting
/* Center content vertically by adding insets
/* Center content horizontally by adding insets
/* Center content by adding insets */
###GON_UITextView+Fitting
// Empty for now
###GON_UITextView+AttributedFitting
/* Update textview text and allow to fit its frame in order to display all text on multiples lines, keeping current width.
/* Update textview text and allows to fit its frame in order to display all text on a single lines.
/* Update textview text and allows to fit its frame in order to display as many text as possible constrained by given height.
/* Update textview text and allows to fit its frame in order to display as many text as possible constrained by given width.
/* Update textview text and allows to fit its frame in order to display as many text as possible constrained by given height.
/* Update textview text and allows to fit its frame in order to display as many text as possible constrained by given width.
##StoreKit
###GON_SKProduct+Utils
/* Return localized price to be displayed to user */
##Versions
0.5 : Initial release<br/>