Latest 1.3.0
Homepage https://github.com/michalkonturek/MKFoundationKit
License MIT
Platforms ios 7.0, requires ARC
Authors

Twitter
License
CocoaPods
Build Status

MKFoundationKit is a collection of categories for NSFoundation classes to accelerate development.

This library is available through CocoaPods.

License

Source code of this project is available under the standard MIT license. Please see the license file.

API

NSArray Additions

NSArray+MK_Block

- (void)mk_apply:(void (^)(id item))block;

- (void)mk_each:(void (^)(id item))block;

- (instancetype)mk_map:(id (^)(id item))block;

- (id)mk_match:(BOOL (^)(id item))block;

- (id)mk_reduce:(id (^)(id item, id aggregate))block;
- (id)mk_reduce:(id)initial withBlock:(id (^)(id item, id aggregate))block;

- (instancetype)mk_reject:(BOOL (^)(id item))block;

- (instancetype)mk_select:(BOOL (^)(id item))block;

- (BOOL)mk_all:(BOOL (^)(id item))block;

- (BOOL)mk_any:(BOOL (^)(id item))block;

- (BOOL)mk_none:(BOOL (^)(id item))block;

NSArray+MK_Misc

- (id)mk_firstObject;

- (id)mk_max;

- (id)mk_min;

- (instancetype)mk_reverse;

- (BOOL)mk_isEmpty;

NSMutableArray+MK_Misc

- (void)mk_safeAddObject:(id)object;

NSMutableArray+MK_Queue

- (void)mk_enqueueObject:(id)object;
- (id)mk_dequeueObject;

NSMutableArray+MK_Stack

- (void)mk_pushObject:(id)object;
- (id)mk_pullObject;

NSBundle Additions

- (NSString *)mk_build;

- (NSString *)mk_name;

- (NSString *)mk_version;

- (NSString *)mk_infoForKey:(id)key;

NSData Additions

NSData+MK_Base64

+ (NSData *)mk_dataWithBase64EncodedString:(NSString *)string;

- (NSString *)mk_base64DecodedString;
- (NSString *)mk_base64EncodedString;

NSDate Additions

NSDate+MK_Comparison

- (BOOL)mk_isToday;
- (BOOL)mk_isTomorrow;
- (BOOL)mk_isYesterday;

- (BOOL)mk_isThisWeek;
- (BOOL)mk_isNextWeek;
- (BOOL)mk_isLastWeek;
- (BOOL)mk_isSameWeekAsDate:(NSDate *)other;

- (BOOL)mk_isThisYear;
- (BOOL)mk_isNextYear;
- (BOOL)mk_isLastYear;
- (BOOL)mk_isSameYearAsDate:(NSDate *)other;

- (BOOL)mk_isEarlierThanDate:(NSDate *)other;
- (BOOL)mk_isLaterThanDate:(NSDate *)other;

- (BOOL)mk_isEqualToDateIgnoringTime:(NSDate *)other;

NSDate+MK_Components

- (NSInteger)mk_year;
- (NSInteger)mk_month;
- (NSInteger)mk_week;
- (NSInteger)mk_weekday;
- (NSInteger)mk_nthWeekday;
- (NSInteger)mk_day;
- (NSInteger)mk_hour;
- (NSInteger)mk_minutes;
- (NSInteger)mk_seconds;

- (NSDateComponents *)mk_components;

NSDate+MK_Creation

+ (NSDate *)mk_dateTomorrow;
+ (NSDate *)mk_dateYesterday;

+ (NSDate *)mk_dateWithoutTime;
+ (NSDate *)mk_dateWithDaysFromNow:(NSInteger)days;
+ (NSDate *)mk_dateFromString:(NSString *)string;
+ (NSDate *)mk_dateFromString:(NSString *)string withFormat:(NSString *)format;

- (NSDate *)mk_dateWithoutTime;

NSDate+MK_Formatting

+ (NSString *)mk_dateFormatCCCCDDMMMYYYY;
+ (NSString *)mk_dateFormatCCCCDDMMMMYYYY;

+ (NSString *)mk_dateFormatDDMMMYYYY;
+ (NSString *)mk_dateFormatDDMMYYYYDashed;
+ (NSString *)mk_dateFormatDDMMYYYYSlashed;

+ (NSString *)mk_dateFormatDDMMMYYYYSlashed;
+ (NSString *)mk_dateFormatMMMDDYYYY;
+ (NSString *)mk_dateFormatYYYYMMDDDashed;

- (NSString *)mk_formattedString;
- (NSString *)mk_formattedStringUsingFormat:(NSString *)dateFormat;

NSDate+MK_Manipulation

- (NSDate *)mk_dateByAddingDays:(NSInteger)days;
- (NSDate *)mk_dateByAddingWeeks:(NSInteger)weeks;
- (NSDate *)mk_dateByAddingMonths:(NSInteger)months;
- (NSDate *)mk_dateByAddingYears:(NSInteger)years;

- (NSDate *)mk_dateByAddingHours:(NSInteger)hours;
- (NSDate *)mk_dateByAddingMinutes:(NSInteger)minutes;
- (NSDate *)mk_dateByAddingSeconds:(NSInteger)seconds;

- (NSDate *)mk_dateBySubtractingDays:(NSInteger)days;
- (NSDate *)mk_dateBySubtractingWeeks:(NSInteger)weeks;
- (NSDate *)mk_dateBySubtractingMonths:(NSInteger)months;
- (NSDate *)mk_dateBySubtractingYears:(NSInteger)years;

- (NSDate *)mk_dateBySubtractingHours:(NSInteger)hours;
- (NSDate *)mk_dateBySubtractingMinutes:(NSInteger)minutes;
- (NSDate *)mk_dateBySubtractingSeconds:(NSInteger)seconds;

- (NSInteger)mk_differenceInDaysToDate:(NSDate *)toDate;
- (NSInteger)mk_differenceInMonthsToDate:(NSDate *)toDate;
- (NSInteger)mk_differenceInYearsToDate:(NSDate *)toDate;

NSDictionary Additions

NSDictionary+MK_Block

- (void)mk_apply:(void (^)(id item))block;

- (void)mk_each:(void (^)(id item))block;

- (instancetype)mk_map:(id (^)(id item))selectorBlock;

- (id)mk_match:(BOOL (^)(id key, id value))conditionBlock;

- (id)mk_reduce:(id)initial withBlock:(id (^)(id item, id aggregate))accumulatorBlock;

- (instancetype)mk_reject:(BOOL (^)(id key, id value))conditionBlock;

- (instancetype)mk_select:(BOOL (^)(id key, id value))conditionBlock;

- (BOOL)mk_all:(BOOL (^)(id key, id value))conditionBlock;

- (BOOL)mk_any:(BOOL (^)(id key, id value))conditionBlock;

- (BOOL)mk_none:(BOOL (^)(id key, id value))conditionBlock;

NSDictionary+MK_Misc

- (NSMutableDictionary *)mk_dictionaryWithKeys:(NSArray *)keys;
- (NSMutableDictionary *)mk_renameKeysUsingMapping:(NSDictionary *)mapping;

- (BOOL)mk_isEmpty;

NSMutableDictionary+MK_Misc

- (void)mk_safeSetObject:(id)object forKey:(id)key;

NSNumber Additions

NSNumber+MK_Comparison

- (BOOL)mk_isTheSame:(NSNumber *)other;

- (BOOL)mk_isGreaterThan:(NSNumber *)other;

- (BOOL)mk_isLessThan:(NSNumber *)other;

- (BOOL)mk_isEven;

- (BOOL)mk_isOdd;

NSNumber+MK_Creation

+ (instancetype)mk_createFrom:(NSNumber *)number;

- (NSDecimalNumber *)mk_decimalNumber;

NSNumber+MK_Fraction

- (instancetype)mk_integralPart;
- (instancetype)mk_fractionalPart;

- (BOOL)mk_isInteger;
- (BOOL)mk_isFraction;

NSNumber+MK_Manipulation

- (instancetype)mk_add:(NSNumber *)other;

- (instancetype)mk_subtract:(NSNumber *)other;

- (instancetype)mk_multiplyBy:(NSNumber *)other;

- (instancetype)mk_divideBy:(NSNumber *)other;

- (instancetype)mk_raiseToPower:(NSInteger)power;

NSNumber+MK_Negative

+ (instancetype)mk_minusOne;

- (instancetype)mk_negative;
- (instancetype)mk_positive;;

- (instancetype)mk_negate;

- (BOOL)mk_isPositive;
- (BOOL)mk_isNegative;

NSNumber+MK_Precison

+ (NSDecimalNumberHandler *)mk_decimalNumberHandlerWithScale:(short)scale;

- (instancetype)mk_roundedAsMoney;
- (instancetype)mk_roundedWithPrecision:(short)precision;

NSObject Additions

NSObject+MK_AutoDescribe

+ (NSArray *)mk_propertyList;
+ (NSArray *)mk_propertyList:(Class)clazz;

+ (NSArray *)mk_methodListOnly;
+ (NSArray *)mk_methodListOnly:(Class)clazz;

+ (NSArray *)mk_methodList;
+ (NSArray *)mk_methodList:(Class)clazz;

- (void)mk_printObject;
- (void)mk_printObjectKeys:(NSArray *)keys;

- (void)mk_printObjectMethods;
- (void)mk_printObjectMethodsOnly;

- (NSString *)mk_className;

NSSet Additions

NSSet+MK_Block

- (void)mk_apply:(void (^)(id item))block;

- (void)mk_each:(void (^)(id item))block;

- (instancetype)mk_map:(id (^)(id item))selectorBlock;

- (id)mk_match:(BOOL (^)(id item))conditionBlock;

- (id)mk_reduce:(id)initial withBlock:(id (^)(id item, id aggregate))accumulatorBlock;

- (instancetype)mk_reject:(BOOL (^)(id item))conditionBlock;

- (instancetype)mk_select:(BOOL (^)(id item))conditionBlock;

- (BOOL)mk_all:(BOOL (^)(id item))conditionBlock;

- (BOOL)mk_any:(BOOL (^)(id item))conditionBlock;

- (BOOL)mk_none:(BOOL (^)(id item))conditionBlock;

NSString Additions

NSString+MK_Base64

- (NSString *)mk_base64DecodedString;
- (NSString *)mk_base64EncodedString;

- (NSData *)mk_base64DecodedData;
- (NSData *)mk_base64EncodedData;

NSString+MK_Conversion

- (NSNumber *)mk_numberWithInteger;
- (NSNumber *)mk_numberWithLongLong;

NSString+MK_Empty

+ (BOOL)mk_isStringEmptyOrNil:(NSString *)value;

- (BOOL)mk_isEmpty;
- (NSString *)mk_trimmedString;

NSString+MK_Misc

- (NSString *)mk_firstComponentUsingSeparators:(NSCharacterSet *)separators;
- (NSString *)mk_lastComponentUsingSeparators:(NSCharacterSet *)separators;
- (NSString *)mk_componentAtIndex:(NSInteger)index usingSeparators:(NSCharacterSet *)separators;

- (BOOL)mk_containsString:(NSString *)term caseSensitive:(BOOL)caseSensitive;

- (NSInteger)mk_countOccurencesOfString:(NSString *)term;
- (NSInteger)mk_countOccurencesOfString:(NSString *)term caseSensitive:(BOOL)caseSensitive;

- (NSInteger)mk_countOccurencesOfStrings:(NSArray *)terms;
- (NSInteger)mk_countOccurencesOfStrings:(NSArray *)terms caseSensitive:(BOOL)caseSensitive;

- (NSRange)mk_range;

NSString+MK_UTF

+ (NSString *)mk_decodeUTF8String:(NSString *)value;

- (NSString *)mk_decodeUTF8;

NSString+MK_UUID

+ (NSString *)mk_stringWithUUID;

NSString+MK_Validation

+ (BOOL)mk_isStringValidEmail:(NSString *)email;

- (BOOL)mk_isValidEmail;

- (BOOL)mk_matchesRegex:(NSString *)regex;

Contributing

  1. Fork it.
  2. Create your feature branch (git checkout -b new-feature).
  3. Commit your changes (git commit -am 'Added new-feature').
  4. Push to the branch (git push origin new-feature).
  5. Create new Pull Request.

Latest podspec

{
    "name": "MKFoundationKit",
    "version": "1.3.0",
    "summary": "Collection of categories for NSFoundation classes to accelerate development.",
    "homepage": "https://github.com/michalkonturek/MKFoundationKit",
    "license": "MIT",
    "authors": {
        "Michal Konturek": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "social_media_url": "https://twitter.com/michalkonturek",
    "source": {
        "git": "https://github.com/michalkonturek/MKFoundationKit.git",
        "tag": "1.3.0"
    },
    "source_files": "Source/**/*.{h,m}",
    "requires_arc": true,
    "subspecs": [
        {
            "name": "AutoDescribe",
            "source_files": "Source/**/*AutoDescribe.{h,m}",
            "requires_arc": true
        },
        {
            "name": "Base64",
            "source_files": "Source/**/*Base64.{h,m}",
            "requires_arc": true
        },
        {
            "name": "Block",
            "source_files": "Source/**/*Block.{h,m}",
            "requires_arc": true
        },
        {
            "name": "Queue",
            "source_files": "Source/**/*Queue.{h,m}",
            "requires_arc": true
        },
        {
            "name": "Stack",
            "source_files": "Source/**/*Stack.{h,m}",
            "requires_arc": true
        },
        {
            "name": "NSArray",
            "source_files": "Source/NSArray/*.{h,m}",
            "requires_arc": true
        },
        {
            "name": "NSBundle",
            "source_files": "Source/NSBundle/*.{h,m}",
            "requires_arc": true
        },
        {
            "name": "NSDate",
            "source_files": "Source/NSDate/*.{h,m}",
            "requires_arc": true
        },
        {
            "name": "NSDictionary",
            "source_files": "Source/NSDictionary/*.{h,m}",
            "requires_arc": true
        },
        {
            "name": "NSNumber",
            "source_files": "Source/NSNumber/*.{h,m}",
            "requires_arc": true
        },
        {
            "name": "NSObject",
            "source_files": "Source/NSObject/*.{h,m}",
            "requires_arc": true
        },
        {
            "name": "NSSet",
            "dependencies": {
                "MKFoundationKit/Block": []
            },
            "source_files": "Source/NSSet/*.{h,m}",
            "requires_arc": true
        },
        {
            "name": "NSString",
            "dependencies": {
                "MKFoundationKit/Base64": []
            },
            "source_files": "Source/NSString/*.{h,m}",
            "requires_arc": true
        }
    ]
}

Pin It on Pinterest

Share This