├── Podfile
├── OverlineTests
├── test_json.json
├── en.lproj
│ └── InfoPlist.strings
├── NSBundle
│ └── NSBundle+ShorthandTest.m
├── NSNull
│ └── NSNull+NaturalTest.m
├── NSString
│ ├── NSString+ShorthandTest.m
│ ├── NSString+ComponentsTest.m
│ ├── NSString+HashTest.m
│ ├── NSString+JSONTest.m
│ ├── NSString+Base64EncodeTest.m
│ ├── NSString+URLEncodeTest.m
│ ├── NSString+RegularExpressionTest.m
│ └── NSString+RegularExpressionTestWithCpp.mm
├── NSArray
│ ├── NSArray+ShorthandTest.m
│ ├── NSArray+SelectorTest.m
│ ├── NSMutableArray
│ │ └── NSMutableArray+ShorthandTest.m
│ ├── NSArray+ReverseTest.m
│ ├── NSArray+DifferenceTest.m
│ ├── NSArray+RandomTest.m
│ ├── NSArray+InitializeTest.m
│ ├── NSArray+SubArrayTest.m
│ └── NSArray+EnumerationTest.m
├── OverlineTests-Info.plist
├── NSURL
│ └── NSURL+ComponentsTest.m
├── NSData
│ └── NSData+Base64EncodeTest.m
├── NSDictionary
│ ├── NSDictionary+PathTest.m
│ ├── NSDictionary+SelectorTest.m
│ └── NSDictionary+EnumerationTest.m
├── NSDateFormatter
│ └── NSDateFormatter+ShorthandTest.m
├── NSNumber
│ └── NSNumber+EqualsTest.m
├── NSObject
│ └── NSObject+EqualsTest.m
└── NSSet
│ └── NSSet+EnumerationTest.m
├── .gitignore
├── .travis.yml
├── Overline.xcworkspace
├── contents.xcworkspacedata
└── xcshareddata
│ └── Overline.xccheckout
├── Overline
├── Over
│ ├── NSString
│ │ ├── NSString+OVDebugging.h
│ │ ├── NSString+OVJSON.h
│ │ ├── NSString+OVComponents.h
│ │ ├── NSString+OVHash.h
│ │ ├── NSString+OVURLEncode.h
│ │ ├── NSString+OVBase64Encode.h
│ │ ├── NSString+OVShorthand.h
│ │ ├── NSString+OVShorthand.m
│ │ ├── NSString+OVJSON.m
│ │ ├── NSString+OVDebugging.m
│ │ ├── NSString+OVURLEncode.m
│ │ ├── NSString+OVComponents.m
│ │ ├── NSString+OVRegularExpression.h
│ │ ├── NSString+OVHash.m
│ │ ├── NSString+OVBase64Encode.m
│ │ └── NSString+OVRegularExpression.m
│ ├── NSArray
│ │ ├── NSArray+OVShorthand.h
│ │ ├── NSArray+OVShorthand.m
│ │ ├── NSArray+OVRandom.h
│ │ ├── NSMutableArray
│ │ │ ├── NSMutableArray+OVShorthand.h
│ │ │ ├── NSMutableArray+OVShorthand.m
│ │ │ ├── NSMutableArray+OVSorting.h
│ │ │ └── NSMutableArray+OVSorting.m
│ │ ├── NSArray+OVReverse.h
│ │ ├── NSArray+OVSelector.h
│ │ ├── NSArray+OVSelector.m
│ │ ├── NSArray+OVInitialize.h
│ │ ├── NSArray+OVDifference.h
│ │ ├── NSArray+OVSubArray.h
│ │ ├── NSArray+OVSorting.h
│ │ ├── NSArray+OVEnumeration.h
│ │ ├── NSArray+OVReverse.m
│ │ ├── NSArray+OVRandom.m
│ │ ├── NSArray+OVSorting.m
│ │ ├── NSArray+OVDifference.m
│ │ ├── NSArray+OVInitialize.m
│ │ ├── NSArray+OVSubArray.m
│ │ └── NSArray+OVEnumeration.m
│ ├── NSURL
│ │ ├── NSURL+OVComponents.h
│ │ ├── NSURL+OVComponents.m
│ │ ├── NSURL+OVDirectories.h
│ │ └── NSURL+OVDirectories.m
│ ├── NSDictionary
│ │ ├── NSDictionary+OVPath.h
│ │ ├── NSDictionary+OVPath.m
│ │ ├── NSDictionary+OVSelector.h
│ │ ├── NSDictionary+OVEnumeration.h
│ │ ├── NSDictionary+OVSelector.m
│ │ └── NSDictionary+OVEnumeration.m
│ ├── NSBundle
│ │ ├── NSBundle+OVShorthand.h
│ │ └── NSBundle+OVShorthand.m
│ ├── NSData
│ │ ├── NSData+OVBase64Encode.h
│ │ └── NSData+OVBase64Encode.m
│ ├── NSObject
│ │ ├── NSObject+Equals.h
│ │ └── NSObject+Equals.m
│ ├── NSMutableDictionary
│ │ ├── NSMutableDictionary+OVShorthand.m
│ │ └── NSMutableDictionary+OVShorthand.h
│ ├── NSNull
│ │ ├── NSNull+OVNatural.h
│ │ └── NSNull+OVNatural.m
│ ├── NSSet
│ │ ├── NSSet+OVEnumeration.h
│ │ └── NSSet+OVEnumeration.m
│ ├── NSDateFormatter
│ │ ├── NSDateFormatter+OVShorthand.h
│ │ └── NSDateFormatter+OVShorthand.m
│ ├── NSNumber
│ │ ├── NSNumber+OVEquals.h
│ │ └── NSNumber+OVEquals.m
│ ├── OVBase64Encode.h
│ ├── NSDate
│ │ ├── NSDate+OVComponents.h
│ │ └── NSDate+OVComponents.m
│ └── NSLayoutConstraint
│ │ ├── NSLayoutConstraint+OVConstructors.h
│ │ └── NSLayoutConstraint+OVConstructors.m
├── Overline-Prefix.pch
├── UIKit
│ ├── UIBezierPath
│ │ ├── UIBezierPath+OVShapes.h
│ │ └── UIBezierPath+OVShapes.m
│ ├── UIImage
│ │ ├── UIImage+OVDrawing.h
│ │ ├── UIImage+OVDrawing.m
│ │ ├── UIImage+OVTransforms.h
│ │ ├── UIImage+OVGradients.h
│ │ ├── UIImage+OVGradients.m
│ │ └── UIImage+OVTransforms.m
│ ├── UIView
│ │ ├── UIView+OVSnapshot.h
│ │ ├── UIView+OVSnapshot.m
│ │ ├── UIView+OVPositioning.h
│ │ └── UIView+OVPositioning.m
│ └── UIColor
│ │ ├── UIColor+OVRandom.h
│ │ ├── UIColor+OVColorAdjust.h
│ │ ├── UIColor+OVRandom.m
│ │ └── UIColor+OVColorAdjust.m
└── Core
│ ├── NSDictionary+OVCore.h
│ ├── NSSet+OVCore.h
│ ├── NSArray+OVCore.h
│ ├── NSDictionary+OVCore.m
│ ├── NSSet+OVCore.m
│ └── NSArray+OVCore.m
├── Podfile.lock
├── Overline.xcodeproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── yaakaito.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcshareddata
│ └── xcschemes
│ └── Jenkins.xcscheme
├── Header
├── Overline+UIKit.h
├── Overline+BlocksKit.h
└── Overline.h
├── Overline.podspec.json
├── Overline-BlocksKit.podspec.json
├── LICENSE
└── README.mkd
/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '5.0'
2 | pod 'OCHamcrest'
3 |
--------------------------------------------------------------------------------
/OverlineTests/test_json.json:
--------------------------------------------------------------------------------
1 | {
2 | "hoge" : "fuga"
3 | }
--------------------------------------------------------------------------------
/OverlineTests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | Pods
2 | .idea
3 | Overline.xcworkspace/xcuserdata
4 | Overline.xcodeproj/xcuserdata
5 | build/
6 | Overline.xcodeproj/xcuserdata
7 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: objective-c
2 |
3 | before_install: gem install cocoapods
4 |
5 | xcode_workspace: Overline.xcworkspace
6 | xcode_scheme: Jenkins
7 | xcode_sdk: iphonesimulator
8 |
--------------------------------------------------------------------------------
/Overline.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Overline/Over/NSString/NSString+OVDebugging.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @interface NSString (OVDebugging)
4 |
5 | + (NSString *)errorCodeStringFromOSStatus:(OSStatus)anOSStatus;
6 |
7 | @end
8 |
--------------------------------------------------------------------------------
/Overline/Overline-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'Overline' target in the 'Overline' project
3 | //
4 |
5 | #ifdef __OBJC__
6 | #import
7 | #endif
8 |
--------------------------------------------------------------------------------
/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - OCHamcrest (1.9)
3 |
4 | DEPENDENCIES:
5 | - OCHamcrest
6 |
7 | SPEC CHECKSUMS:
8 | OCHamcrest: f8393efd5a49d91879be573635d6183effacc0ab
9 |
10 | COCOAPODS: 0.18.1
11 |
--------------------------------------------------------------------------------
/Overline.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Overline.xcodeproj/project.xcworkspace/xcuserdata/yaakaito.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yaakaito/Overline/HEAD/Overline.xcodeproj/project.xcworkspace/xcuserdata/yaakaito.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVShorthand.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 2/8/13.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSArray (OVShorthand)
11 | - (BOOL)isEmpty;
12 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSString/NSString+OVJSON.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/01/02.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSString (OVJSON)
11 | - (id)JSON;
12 | - (id)jsonObject;
13 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSURL/NSURL+OVComponents.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/16.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSURL (OVComponents)
11 | - (NSDictionary *)queryComponents;
12 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSDictionary/NSDictionary+OVPath.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/01/10.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSDictionary (OVPath)
11 | - (id)objectForPath:(NSString *)path;
12 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSBundle/NSBundle+OVShorthand.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/25.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSBundle (OVShorthand)
11 | - (id)JSONForResourceName:(NSString *)resourceName;
12 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVShorthand.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 2/8/13.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSArray+OVShorthand.h"
9 |
10 |
11 | @implementation NSArray (OVShorthand)
12 | - (BOOL)isEmpty {
13 | return self.count == 0U;
14 | }
15 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVRandom.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/22.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSArray (OVRandom)
11 | - (NSArray *)shuffle;
12 | - (NSArray *)shuffledArray;
13 | - (id)anyObject;
14 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSData/NSData+OVBase64Encode.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/01/05.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSData (OVBase64Encode)
11 | - (NSString *)base64Encode;
12 | - (NSString *)stringUsingEncodingBase64;
13 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSMutableArray/NSMutableArray+OVShorthand.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/01/05.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSMutableArray (OVShorthand)
11 | - (void)insertObjects:(NSArray *)objects atIndex:(NSUInteger)index;
12 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVReverse.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 2/8/13.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSArray (OVReverse)
11 | - (NSArray *)reverse;
12 | - (NSArray *)reversedArray;
13 | - (NSArray *)objectAtReversedIndex:(NSUInteger)index;
14 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSString/NSString+OVComponents.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/16.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSString (OVComponents)
11 |
12 | - (NSDictionary *)componentsSeparatedByInnerString:(NSString *)inner andOuterString:(NSString *)outer;
13 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSString/NSString+OVHash.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/25.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSString (OVHash)
11 | - (NSString *)sha256;
12 | - (NSString *)stringByHashingSha256;
13 | - (NSString *)md5;
14 | - (NSString *)stringByHashingMD5;
15 | @end
--------------------------------------------------------------------------------
/Overline/UIKit/UIBezierPath/UIBezierPath+OVShapes.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIBezierPath+OVShapes.h
3 | // AC-Sabre
4 | //
5 | // Created by Hari Karam Singh on 05/06/2014.
6 | //
7 | //
8 |
9 | #import
10 |
11 | @interface UIBezierPath (OVShapes)
12 |
13 | + (instancetype)bezierPathEquilaterialTriangleWithSideLength:(CGFloat)sideLength rotation:(CGFloat)rotation;
14 |
15 | @end
16 |
17 |
--------------------------------------------------------------------------------
/Overline/Over/NSObject/NSObject+Equals.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 12/27/12.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSObject (Equals)
11 | - (BOOL)isNullObject;
12 | - (BOOL)isArray;
13 | - (BOOL)isDictionary;
14 | - (BOOL)isSet;
15 | - (BOOL)isString;
16 | - (BOOL)isNumber;
17 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVSelector.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 | #import
8 |
9 | @interface NSArray (OVSelector)
10 |
11 | /** Returns first object in array or nil if none (unlike -objectAtIndex:0 which throws NSRangeException) */
12 | - (id)firstObject;
13 | @end
14 |
--------------------------------------------------------------------------------
/Overline/Over/NSString/NSString+OVURLEncode.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/30.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSString (OVURLEncode)
11 | - (NSString *)URLEncode;
12 | - (NSString *)stringByEncodingURL;
13 | - (NSString *)URLDecode;
14 | - (NSString *)stringByDecodingURL;
15 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVSelector.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/01.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 | #import "NSArray+OVSelector.h"
8 |
9 | @implementation NSArray (OVSelector)
10 |
11 | - (id)firstObject {
12 | if (self.count == 0) {
13 | return nil;
14 | }
15 | return [self objectAtIndex:0];
16 | }
17 | @end
18 |
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVInitialize.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 2/8/13.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSArray (OVInitialize)
11 | + (instancetype)arrayWithRangeFrom:(NSInteger)from to:(NSInteger)to;
12 | + (instancetype)arrayWithRangeFrom:(NSInteger)from to:(NSInteger)to step:(NSUInteger)step;
13 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSMutableDictionary/NSMutableDictionary+OVShorthand.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSMutableDictionary+OVShorthand.m
3 | // Overline
4 | //
5 | // Created by Hari Karam Singh on 03/06/2014.
6 | //
7 | //
8 |
9 | #import "NSMutableDictionary+OVShorthand.h"
10 |
11 | @implementation NSMutableDictionary (OVShorthand)
12 |
13 | - (NSDictionary *)immutableCopy
14 | {
15 | return [NSDictionary dictionaryWithDictionary:self];
16 | }
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/Overline/Over/NSURL/NSURL+OVComponents.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/16.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSURL+OVComponents.h"
9 | #import "NSString+OVComponents.h"
10 |
11 |
12 | @implementation NSURL (OVComponents)
13 | - (NSDictionary *)queryComponents {
14 | return [[self query] componentsSeparatedByInnerString:@"=" andOuterString:@"&"];
15 | }
16 | @end
--------------------------------------------------------------------------------
/Overline/Core/NSDictionary+OVCore.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 3/29/13.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSDictionary (OVCore)
11 | - (void)each:(void (^)(id obj, NSString *key))block;
12 | - (NSDictionary *)map:(id (^)(id obj, NSString *key))block;
13 | - (id)reduce:(id (^)(id memo, id obj, NSString *key))block memo:(id)memo;
14 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSMutableDictionary/NSMutableDictionary+OVShorthand.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSMutableDictionary+OVShorthand.h
3 | // Overline
4 | //
5 | // Created by Hari Karam Singh on 03/06/2014.
6 | //
7 | //
8 |
9 | #import
10 |
11 | @interface NSMutableDictionary (OVShorthand)
12 |
13 | /** Returns a shallow immutable copy of the dict using `[NSDictionary dictionaryWithDictionary:]` */
14 | - (NSDictionary *)immutableCopy;
15 |
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/Overline/Over/NSString/NSString+OVBase64Encode.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/01/05.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSString (OVBase64Encode)
11 | - (NSString *)encodeBase64;
12 | - (NSString *)stringByEncodingBase64;
13 | - (NSString *)decodeBase64;
14 | - (NSString *)stringByDecodingBase64;
15 | - (NSData *)dataUsingDecodingBase64;
16 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVDifference.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 2/8/13.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSArray (OVDifference)
11 | - (NSArray *)difference:(NSArray *)array;
12 | - (NSArray *)arrayDifferenceWithArray:(NSArray *)array;
13 | - (NSArray *)unionise:(NSArray *)array;
14 | - (NSArray *)arrayByUnionisingArray:(NSArray *)array;
15 | @end
--------------------------------------------------------------------------------
/Overline/Core/NSSet+OVCore.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 3/29/13.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSSet (OVCore)
11 | - (void)each:(void (^)(id obj))block;
12 | - (NSSet *)map:(id (^)(id obj))block;
13 | - (NSSet *)filter:(BOOL (^)(id obj))block;
14 | - (NSSet *)reject:(BOOL (^)(id obj))block;
15 | - (id)reduce:(id (^)(id memo, id obj))block memo:(id)memo;
16 |
17 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSNull/NSNull+OVNatural.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 12/27/12.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | // http://stackoverflow.com/questions/2060741/does-objective-c-use-short-circuit-evaluation
11 |
12 | @interface NSNull (OVNatural)
13 | - (void)forwardInvocation:(NSInvocation *)anInvocation;
14 | - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector;
15 | @end
16 |
--------------------------------------------------------------------------------
/Header/Overline+UIKit.h:
--------------------------------------------------------------------------------
1 | //
2 | // Overline+UIKit.h
3 | // Overline
4 | //
5 | // Created by Hari Karam Singh on 22/05/2014.
6 | // Copyright (c) 2014 Air Craft Media Ltd. MIT License.
7 | //
8 |
9 | #import "UIBezierPath+OVShapes.h"
10 |
11 | #import "UIColor+OVColorAdjust.h"
12 | #import "UIColor+OVRandom.h"
13 |
14 | #import "UIImage+OVDrawing.h"
15 | #import "UIImage+OVGradients.h"
16 | #import "UIImage+OVTransforms.h"
17 |
18 | #import "UIView+OVPositioning.h"
19 | #import "UIView+OVSnapshot.h"
20 |
--------------------------------------------------------------------------------
/Overline/Over/NSString/NSString+OVShorthand.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/25.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSString (OVShorthand)
11 |
12 | /** Trims whitespace and newlines from the ends of the string */
13 | - (NSString *)trim;
14 |
15 | /** Trim the ends of the string with the characters in the provided string */
16 | - (NSString *)trim:(NSString *)characters;
17 | @end
--------------------------------------------------------------------------------
/Overline/UIKit/UIImage/UIImage+OVDrawing.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+OVDrawing.h
3 | // AC-Sabre
4 | //
5 | // Created by Hari Karam Singh on 05/06/2014.
6 | //
7 | //
8 |
9 | #import
10 |
11 | @interface UIImage (OVDrawing)
12 |
13 | /** Create an image from the bezierpath and the given colors. Pass nil for a color to have it not draw that portion */
14 | + (UIImage *)imageFromBezierPath:(UIBezierPath *)path withFillColor:(UIColor *)fillColor strokeColor:(UIColor *)strokeColor;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSMutableArray/NSMutableArray+OVShorthand.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/01/05.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSMutableArray+OVShorthand.h"
9 |
10 |
11 | @implementation NSMutableArray (OVShorthand)
12 | - (void)insertObjects:(NSArray *)objects atIndex:(NSUInteger)index
13 | {
14 | [self insertObjects:objects atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(index, [objects count])]];
15 | }
16 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSSet/NSSet+OVEnumeration.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/01/04.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSSet (OVEnumeration)
11 |
12 | - (NSSet *)mappedSetUsingBlock:(id (^)(id obj))block;
13 | - (id)reducedObjectByBlock:(id (^)(id memo, id obj))block memo:(id)memo;
14 | - (NSSet *)filteredSetUsingBlock:(BOOL (^)(id obj))block;
15 | - (NSSet *)rejectedSetUsingBlock:(BOOL (^)(id obj))block;
16 | @end
--------------------------------------------------------------------------------
/Overline/Core/NSArray+OVCore.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 3/29/13.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSArray (OVCore)
11 | - (void)each:(void (^)(id obj, NSUInteger idx))block;
12 | - (NSArray *)map:(id (^)(id obj, NSUInteger idx))block;
13 | - (id)reduce:(id (^)(id memo, id obj))block memo:(id)memo;
14 | - (NSArray *)filter:(BOOL (^)(id obj, NSUInteger idx))block;
15 | - (NSArray *)reject:(BOOL (^)(id obj, NSUInteger idx))block;
16 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSBundle/NSBundle+OVShorthand.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/25.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSBundle+OVShorthand.h"
9 |
10 | @implementation NSBundle (OVShorthand)
11 | - (id)JSONForResourceName:(NSString *)resourceName {
12 | NSData *jsonData = [NSData dataWithContentsOfFile:[self pathForResource:resourceName ofType:@"json"]];
13 | return [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments error:NULL];
14 | }
15 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVSubArray.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/01/10.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSArray (OVSubArray)
11 | - (NSArray *)subarrayFromIndex:(NSUInteger)index;
12 | - (NSArray *)subarrayFromIndex:(NSUInteger)index length:(NSUInteger)length;
13 | - (NSArray *)subarrayToIndex:(NSUInteger)index;
14 | - (NSArray *)uniqueObjects;
15 | - (NSArray *)uniqueObjectsUsingEqualsBlock:(BOOL (^)(id left, id right))block;
16 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSDateFormatter/NSDateFormatter+OVShorthand.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/03/28.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSDateFormatter (OVShorthand)
11 | + (instancetype)dateFormatterWithCalendarIndentifiter:(NSString *)calendar
12 | localeIdentifiter:(NSString *)locale
13 | timeZoneAbbreviation:(NSString *)timeZone;
14 | + (instancetype)userDefaultFormatter;
15 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSMutableArray/NSMutableArray+OVSorting.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSMutableArray+Sorting.h
3 | // Overline
4 | //
5 | // Created by Hari Karam Singh on 06/08/2013.
6 | // Copyright (c) 2013 Overline. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSMutableArray (OVSorting)
12 |
13 | /** Sort the array according to compare: */
14 | - (void)sortDescending:(BOOL)shouldBeDescending;
15 |
16 | /** Shorthand for -sortDescending:NO */
17 | - (void)sortAsc;
18 |
19 | /** Shorthand for -sortDescending:YES */
20 | - (void)sortDesc;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/Overline/Over/NSString/NSString+OVShorthand.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/25.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSString+OVShorthand.h"
9 |
10 |
11 | @implementation NSString (OVShorthand)
12 |
13 | - (NSString *)trim {
14 | return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
15 | }
16 |
17 | - (NSString *)trim:(NSString *)characters
18 | {
19 | return [self stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:characters]];
20 | }
21 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVSorting.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+Sorting.h
3 | // Overline
4 | //
5 | // Created by Hari Karam Singh on 06/08/2013.
6 | // Copyright (c) 2013 Overline. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSArray (OVSorting)
12 |
13 | /** Return the array sorted according to compare: */
14 | - (NSArray *)arraySortedDescending:(BOOL)shouldBeDescending;
15 |
16 | /** Shorthand for -arraySortedDescending:NO */
17 | - (NSArray *)arraySortedAsc;
18 |
19 | /** Shorthand for -arraySortedDescending:YES */
20 | - (NSArray *)arraySortedDesc;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/Overline/UIKit/UIView/UIView+OVSnapshot.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+OVSnapshot.h
3 | // Overline
4 | //
5 | // Created by Hari Karam Singh on 22/05/2014.
6 | // Copyright (c) 2014 Air Craft Media Ltd. MIT License.
7 | //
8 | //
9 |
10 | #import
11 |
12 | @interface UIView (OVSnapshot)
13 |
14 |
15 | /** Similar to snapshot... but uses the old
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSBundle+OVShorthand.h"
13 |
14 | @interface NSBundle_ShorthandTest : SenTestCase
15 | {
16 |
17 | }
18 | @end
19 |
20 | @implementation NSBundle_ShorthandTest
21 |
22 | - (void)testJSONForResourceName {
23 | id JSON = [[NSBundle bundleForClass:[self class]] JSONForResourceName:@"test_json"];
24 | assertThat(JSON, equalTo(@{@"hoge":@"fuga"}));
25 | }
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/OverlineTests/NSNull/NSNull+NaturalTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSNull+NaturalTest.m
3 | // Copyright 2012 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: kazuma.ukyo
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSNull+OVNatural.h"
13 |
14 | @interface NSNull_NaturalTest : SenTestCase
15 | {
16 |
17 | }
18 | @end
19 |
20 | @implementation NSNull_NaturalTest
21 |
22 | - (void)testNatural
23 | {
24 | NSDictionary *dic = @{
25 | @"null-key" : [NSNull null]
26 | };
27 | assertThat([[dic objectForKey:@"null-key"] objectForKey:@"fail"], equalTo(nil));
28 | }
29 | @end
30 |
--------------------------------------------------------------------------------
/Overline/Over/NSString/NSString+OVJSON.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/01/02.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSString+OVJSON.h"
9 |
10 |
11 | @implementation NSString (OVJSON)
12 | - (id)JSON {
13 | return [self jsonObject];
14 | }
15 |
16 | - (id)jsonObject {
17 | NSError *error = nil;
18 | id JSON = [NSJSONSerialization JSONObjectWithData:[self dataUsingEncoding:NSUTF8StringEncoding]
19 | options:NSJSONReadingAllowFragments
20 | error:&error];
21 | if (error) {
22 | return nil;
23 | }
24 |
25 | return JSON;
26 | }
27 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVEnumeration.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/04.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSArray (OVEnumeration)
11 |
12 | - (NSArray *)mappedArrayUsingBlock:(id (^)(id obj, NSUInteger idx))block;
13 | - (id)reducedObjectByBlock:(id (^)(id memo, id obj))block memo:(id)memo;
14 | - (id)find:(BOOL (^)(id obj, NSUInteger idx))block;
15 | - (id)objectUsingBlock:(BOOL (^)(id obj, NSUInteger idx))block;
16 | - (NSArray *)filteredArrayUsingBlock:(BOOL (^)(id obj, NSUInteger idx))block;
17 | - (NSArray *)rejectedArrayUsingBlock:(BOOL (^)(id obj, NSUInteger idx))block;
18 | @end
--------------------------------------------------------------------------------
/OverlineTests/NSString/NSString+ShorthandTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSString+ShorthandTest.m
3 | // Copyright 2012 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSString+OVShorthand.h"
13 |
14 | @interface NSString_ShorthandTest : SenTestCase
15 | {
16 |
17 | }
18 | @end
19 |
20 | @implementation NSString_ShorthandTest
21 |
22 | - (void)testTrim {
23 | assertThat([@" hoge " trim], equalTo(@"hoge"));
24 | }
25 |
26 | - (void)testTrimWithChars
27 | {
28 | assertThat([@"!@$howdy^%z " trim:@"!@$^%z "], equalTo(@"howdy"));
29 | }
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/Overline/Over/NSString/NSString+OVDebugging.m:
--------------------------------------------------------------------------------
1 | #import "NSString+OVDebugging.h"
2 |
3 | @implementation NSString (OVDebugging)
4 |
5 | + (NSString *)errorCodeStringFromOSStatus:(OSStatus)anOSStatus
6 | {
7 | char str[10]="";
8 | OSStatus error = anOSStatus;
9 |
10 | // see if it appears to be a 4-char-code
11 | *(UInt32 *)(str + 1) = CFSwapInt32HostToBig(error);
12 | if (isprint(str[1]) && isprint(str[2]) && isprint(str[3]) && isprint(str[4])) {
13 | str[0] = str[5] = '\'';
14 | str[6] = '\0';
15 | } else {
16 | // no, format it as an integer
17 | sprintf(str, "%d", (int)error);
18 | }
19 |
20 | return [NSString stringWithUTF8String:str];
21 | }
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/OverlineTests/NSArray/NSArray+ShorthandTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSArray+ShorthandTest.m
3 | // Copyright 2013 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: kazuma.ukyo
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 | #import "NSArray+OVShorthand.h"
12 |
13 | @interface NSArray_ShorthandTest : SenTestCase
14 | {
15 |
16 | }
17 | @end
18 |
19 | @implementation NSArray_ShorthandTest
20 |
21 | - (void)testIsEmpty
22 | {
23 | assertThatBool([(@[]) isEmpty], equalToBool(YES));
24 | assertThatBool([[NSArray array] isEmpty], equalToBool(YES));
25 | assertThatBool([(@[@1, @2]) isEmpty], equalToBool(NO));
26 | }
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/Overline/Over/NSNumber/NSNumber+OVEquals.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 12/27/12.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSNumber (OVEquals)
11 | - (BOOL)isEqualToInt:(int)value;
12 | - (BOOL)isEqualToInteger:(NSInteger)value;
13 | - (BOOL)isEqualToUnsignedInt:(unsigned int)value;
14 | - (BOOL)isEqualToUnsignedInteger:(NSUInteger)value;
15 | - (BOOL)isEqualToLong:(long)value;
16 | - (BOOL)isEqualToLongLong:(long long)value;
17 | - (BOOL)isEqualToUnsignedLong:(unsigned long)value;
18 | - (BOOL)isEqualToUnsignedLongLong:(unsigned long long)value;
19 | - (BOOL)isEqualToDouble:(double)value;
20 | - (BOOL)isEqualToFloat:(float)value;
21 | @end
--------------------------------------------------------------------------------
/Overline/Core/NSDictionary+OVCore.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 3/29/13.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSDictionary+OVCore.h"
9 | #import "NSDictionary+OVEnumeration.h"
10 |
11 | @implementation NSDictionary (OVCore)
12 | - (void)each:(void (^)(id, NSString *))block {
13 | [self enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
14 | block(obj, key);
15 | }];
16 | }
17 |
18 | - (NSDictionary *)map:(id (^)(id, NSString *))block {
19 | return [self mappedDictionaryUsingBlock:block];
20 | }
21 |
22 | - (id)reduce:(id (^)(id, id, NSString *))block memo:(id)memo {
23 | return [self reducedObjectUsingBlock:block memo:memo];
24 | }
25 |
26 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSNull/NSNull+OVNatural.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 12/27/12.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSNull+OVNatural.h"
9 |
10 | @implementation NSNull (OVNatural)
11 | - (void)forwardInvocation:(NSInvocation *)invocation
12 | {
13 | if ([self respondsToSelector:[invocation selector]]) {
14 | [invocation invokeWithTarget:self];
15 | }
16 | }
17 |
18 | - (NSMethodSignature *)methodSignatureForSelector:(SEL)selector
19 | {
20 | NSMethodSignature *sig = [[NSNull class] instanceMethodSignatureForSelector:selector];
21 | if(sig == nil) {
22 | sig = [NSMethodSignature signatureWithObjCTypes:"@^v^c"];
23 | }
24 | return sig;
25 | }
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/OverlineTests/NSArray/NSArray+SelectorTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+SelectorTest.m
3 | // Overline
4 | //
5 | // Created by yaakaito on 12/01/12.
6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved.
7 | //
8 |
9 | #import samsa
10 | #import "NSArray+OVSelector.h"
11 | #define HC_SHORTHAND
12 | #import
13 |
14 | @interface NSArray_SelectorTest : SenTestCase
15 |
16 | @end
17 |
18 | @implementation NSArray_SelectorTest
19 |
20 | - (void)testFirstObject {
21 | assertThat([@[@"a"] firstObject], equalTo(@"a"));
22 | assertThat(([@[@"b", @"c", @"d"] firstObject]), equalTo(@"b"));
23 | assertThat(([@[@[@"a",@"b"], @[@"c", @"d"], @[@"e", @"f"]] firstObject]), equalTo(@[@"a", @"b"]));
24 | }
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/OverlineTests/NSArray/NSMutableArray/NSMutableArray+ShorthandTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSMutableArray+ShorthandTest.m
3 | // Copyright 2013 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 | #import "NSMutableArray+OVShorthand.h"
12 |
13 | @interface NSMutableArray_ShorthandTest : SenTestCase
14 | {
15 |
16 | }
17 | @end
18 |
19 | @implementation NSMutableArray_ShorthandTest
20 |
21 | - (void)testInsertObjects {
22 | NSMutableArray *marray = [NSMutableArray arrayWithArray:@[@1,@2,@3]];
23 | [marray insertObjects:@[@4,@5,@6] atIndex:1];
24 | assertThat(marray, equalTo(@[@1,@4,@5,@6,@2,@3]));
25 | }
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVReverse.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 2/8/13.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSArray+OVReverse.h"
9 |
10 |
11 | @implementation NSArray (OVReverse)
12 |
13 | - (NSArray *)reverse {
14 | return [self reversedArray];
15 | }
16 |
17 | - (NSArray *)reversedArray {
18 | NSMutableArray *array = [NSMutableArray arrayWithCapacity:self.count];
19 | NSEnumerator *enumerator = [self reverseObjectEnumerator];
20 | for (id obj in enumerator) {
21 | [array addObject:obj];
22 | }
23 | return [NSArray arrayWithArray:array];
24 | }
25 |
26 | - (NSArray *)objectAtReversedIndex:(NSUInteger)index {
27 | return [[self reversedArray] objectAtIndex:index];
28 | }
29 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSObject/NSObject+Equals.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 12/27/12.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSObject+Equals.h"
9 |
10 |
11 | @implementation NSObject (Equals)
12 | - (BOOL)isNullObject {
13 | return [self isEqual:[NSNull null]];
14 | }
15 |
16 | - (BOOL)isArray {
17 | return [self isKindOfClass:[NSArray class]];
18 | }
19 |
20 | - (BOOL)isDictionary {
21 | return [self isKindOfClass:[NSDictionary class]];
22 | }
23 |
24 | - (BOOL)isSet {
25 | return [self isKindOfClass:[NSSet class]];
26 | }
27 |
28 | - (BOOL)isString {
29 | return [self isKindOfClass:[NSString class]];
30 | }
31 |
32 | - (BOOL)isNumber {
33 | return [self isKindOfClass:[NSNumber class]];
34 | }
35 | @end
--------------------------------------------------------------------------------
/OverlineTests/OverlineTests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | org.yaakaito.${PRODUCT_NAME:rfc1034identifier}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Overline.podspec.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Overline",
3 | "version": "0.4.0",
4 | "summary": "Objective-C utilities and shorthands.",
5 | "homepage": "https://github.com/yaakaito/Overline",
6 | "license": {
7 | "type": "MIT",
8 | "file": "LICENSE"
9 | },
10 | "platforms": {
11 | "ios": null
12 | },
13 | "authors": {
14 | "KAZUMA Ukyo": "yaakaito@gmail.com"
15 | },
16 | "source": {
17 | "git": "https://github.com/yaakaito/Overline.git",
18 | "tag": "0.4.0"
19 | },
20 | "source_files": [
21 | "Overline",
22 | "Overline/**/*.{h,m}",
23 | "Header/Overline.h",
24 | "Header/Overline-UIKit.h"
25 | ],
26 | "public_header_files": [
27 | "Overline/**/*.h",
28 | "Header/Overline.h",
29 | "Header/Overline-UIKit.h"
30 | ],
31 | "requires_arc": true
32 | }
33 |
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVRandom.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/22.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSArray+OVRandom.h"
9 |
10 |
11 | @implementation NSArray (OVRandom)
12 |
13 | - (NSArray *)shuffle {
14 | return [self shuffledArray];
15 | }
16 |
17 | - (NSArray *)shuffledArray {
18 | NSMutableArray *shuffled = [self mutableCopy];
19 | for (NSInteger i = [shuffled count] - 1; i > 0; i--) {
20 | [shuffled exchangeObjectAtIndex:arc4random() % (i + 1)
21 | withObjectAtIndex:i];
22 | }
23 | return shuffled;
24 | }
25 |
26 | - (id)anyObject {
27 | return [self count] ?
28 | [self objectAtIndex:arc4random() % [self count]] :
29 | nil;
30 | }
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/OverlineTests/NSURL/NSURL+ComponentsTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSURL+ComponentsTest.m
3 | // Copyright 2012 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 | #import "NSURL+OVComponents.h"
12 |
13 | @interface NSURL_ComponentsTest : SenTestCase
14 | {
15 |
16 | }
17 | @end
18 |
19 | @implementation NSURL_ComponentsTest
20 |
21 | - (void)testQueryComponents
22 | {
23 | NSURL *url = [NSURL URLWithString:@"http://example.com/?hoge=fuga&piyo=foo"];
24 | NSDictionary *actual = [url queryComponents];
25 | NSDictionary *expect = @{
26 | @"hoge" : @"fuga",
27 | @"piyo" : @"foo"
28 | };
29 | assertThat(actual, equalTo(expect));
30 | }
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/Overline/UIKit/UIColor/UIColor+OVRandom.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIColor+OVRandom.h
3 | // AC-Sabre
4 | //
5 | // Created by Hari Karam Singh on 04/06/2014.
6 | //
7 | //
8 |
9 | #import
10 |
11 | @interface UIColor (OVRandom)
12 |
13 | /** Returns a random solid (alpha=1) color */
14 | + (UIColor *)randomColor;
15 |
16 | /** Returns a random color with te specified alpha */
17 | + (UIColor *)randomColorWithAlpha:(CGFloat)alpha;
18 |
19 | /** Max saturation, brightness & alpha */
20 | + (UIColor *)randomHue;
21 |
22 | /** Random color with specified alpha but with max saturation and brightness. The most useful verison for debugging imo. */
23 | + (UIColor *)randomHueWithAlpha:(CGFloat)alpha;
24 |
25 | /** Randomises just the hue */
26 | + (UIColor *)randomHueWithSaturation:(CGFloat)s brightness:(CGFloat)b alpha:(CGFloat)a;
27 |
28 |
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/OverlineTests/NSData/NSData+Base64EncodeTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSData+Base64EncodeTest.m
3 | // Copyright 2013 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 | #import "NSData+OVBase64Encode.h"
12 |
13 |
14 | @interface NSData_Base64EncodeTest : SenTestCase
15 | {
16 |
17 | }
18 | @end
19 |
20 | @implementation NSData_Base64EncodeTest
21 |
22 | - (void)testBase64Encode {
23 | NSData *data = [@"a" dataUsingEncoding:NSUTF8StringEncoding];
24 | assertThat([data base64Encode], equalTo(@"YQ=="));
25 | }
26 |
27 | - (void)testStringByEncoding {
28 | NSData *data = [@"a" dataUsingEncoding:NSUTF8StringEncoding];
29 | assertThat([data stringUsingEncodingBase64], equalTo(@"YQ=="));
30 | }
31 | @end
32 |
--------------------------------------------------------------------------------
/Overline/Core/NSSet+OVCore.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 3/29/13.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSSet+OVCore.h"
9 | #import "NSSet+OVEnumeration.h"
10 |
11 | @implementation NSSet (OVCore)
12 | - (void)each:(void (^)(id))block {
13 | [self enumerateObjectsUsingBlock:^(id obj, BOOL *stop) {
14 | block(obj);
15 | }];
16 | }
17 |
18 | - (NSSet *)map:(id (^)(id))block {
19 | return [self mappedSetUsingBlock:block];
20 | }
21 |
22 | - (id)reduce:(id (^)(id, id))block memo:(id)memo {
23 | return [self reducedObjectByBlock:block memo:memo];
24 | }
25 |
26 | - (NSSet *)filter:(BOOL (^)(id))block {
27 | return [self filteredSetUsingBlock:block];
28 | }
29 |
30 | - (NSSet *)reject:(BOOL (^)(id))block {
31 | return [self rejectedSetUsingBlock:block];
32 | }
33 | @end
--------------------------------------------------------------------------------
/Overline-BlocksKit.podspec.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Overline-BlocksKit",
3 | "version": "0.4.0",
4 | "summary": "Objective-C utilities and shorthands. version for BlocksKit.",
5 | "homepage": "https://github.com/yaakaito/Overline",
6 | "license": {
7 | "type": "MIT",
8 | "file": "LICENSE"
9 | },
10 | "platforms": {
11 | "ios": null
12 | },
13 | "authors": {
14 | "KAZUMA Ukyo": "yaakaito@gmail.com"
15 | },
16 | "source": {
17 | "git": "https://github.com/yaakaito/Overline.git",
18 | "tag": "0.4.0"
19 | },
20 | "source_files": [
21 | "Overline",
22 | "Overline/Over/**/*.{h,m}",
23 | "Header/Overline+BlocksKit.h",
24 | "Header/Overline-UIKit.h"
25 | ],
26 | "public_header_files": [
27 | "Overline/**/*.h",
28 | "Header/Overline+BlocksKit.h",
29 | "Header/Overline-UIKit.h"
30 | ],
31 | "requires_arc": true
32 | }
--------------------------------------------------------------------------------
/OverlineTests/NSString/NSString+ComponentsTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSString+ComponentsTest.m
3 | // Copyright 2012 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSString+OVComponents.h"
13 |
14 | @interface NSString_ComponentsTest : SenTestCase
15 | {
16 |
17 | }
18 | @end
19 |
20 | @implementation NSString_ComponentsTest
21 |
22 | - (void)testComponentsByInnerAndOuter
23 | {
24 | NSString *base = @"hoge=fuga&piyo=foo";
25 | NSDictionary *actual = [base componentsSeparatedByInnerString:@"=" andOuterString:@"&"];
26 | NSDictionary *expect = @{
27 | @"hoge" : @"fuga",
28 | @"piyo" : @"foo"
29 | };
30 | assertThat(actual, equalTo(expect));
31 | }
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/Overline/UIKit/UIImage/UIImage+OVDrawing.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+OVDrawing.m
3 | // AC-Sabre
4 | //
5 | // Created by Hari Karam Singh on 05/06/2014.
6 | //
7 | //
8 |
9 | #import "UIImage+OVDrawing.h"
10 |
11 | @implementation UIImage (OVDrawing)
12 |
13 | + (UIImage *)imageFromBezierPath:(UIBezierPath *)path withFillColor:(UIColor *)fillColor strokeColor:(UIColor *)strokeColor
14 | {
15 | UIImage *img;
16 | UIGraphicsBeginImageContextWithOptions(path.bounds.size, NO, 0.0);
17 | {
18 | if (fillColor) {
19 | [fillColor setFill];
20 | [path fill];
21 | }
22 | if (strokeColor) {
23 | [strokeColor setStroke];
24 | [path stroke];
25 | }
26 |
27 | img = UIGraphicsGetImageFromCurrentImageContext();
28 | }
29 | UIGraphicsEndImageContext();
30 |
31 | return img;
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/Overline/Over/NSString/NSString+OVURLEncode.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/30.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSString+OVURLEncode.h"
9 |
10 |
11 | @implementation NSString (OVURLEncode)
12 |
13 | - (NSString *)URLEncode {
14 | return [self stringByEncodingURL];
15 | }
16 |
17 | - (NSString *)stringByEncodingURL {
18 | return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (__bridge CFStringRef)self, NULL, (__bridge CFStringRef)@"!*'();:@&=+$.,/?%#[]", kCFStringEncodingUTF8);
19 | }
20 |
21 | - (NSString *)URLDecode {
22 | return [self stringByDecodingURL];
23 | }
24 |
25 | - (NSString *)stringByDecodingURL {
26 | return (__bridge_transfer NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL, (__bridge CFStringRef)self, CFSTR(""), kCFStringEncodingUTF8);
27 | }
28 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSString/NSString+OVComponents.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/16.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSString+OVComponents.h"
9 |
10 |
11 | @implementation NSString (OVComponents)
12 | - (NSDictionary *)componentsSeparatedByInnerString:(NSString *)inner andOuterString:(NSString *)outer {
13 | NSArray *first = [self componentsSeparatedByString:outer];
14 |
15 | NSInteger count = [first count];
16 | NSMutableDictionary *returnDictionary = [NSMutableDictionary dictionaryWithCapacity:count];
17 | for (NSInteger i = 0; i < count; i++) {
18 | NSArray *second = [(NSString *)[first objectAtIndex:i] componentsSeparatedByString:inner];
19 | if ([second count] == 2) {
20 | [returnDictionary setObject:[second objectAtIndex:1] forKey:[second objectAtIndex:0]];
21 | }
22 | }
23 |
24 | return returnDictionary;
25 | }
26 | @end
--------------------------------------------------------------------------------
/Overline/Core/NSArray+OVCore.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 3/29/13.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSArray+OVCore.h"
9 | #import "NSArray+OVEnumeration.h"
10 |
11 | @implementation NSArray (OVCore)
12 |
13 | - (void)each:(void (^)(id, NSUInteger))block {
14 | [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
15 | block(obj, idx);
16 | }];
17 | }
18 |
19 | - (NSArray *)map:(id (^)(id, NSUInteger))block {
20 | return [self mappedArrayUsingBlock:block];
21 | }
22 |
23 | - (id)reduce:(id (^)(id, id))block memo:(id)memo {
24 | return [self reducedObjectByBlock:block memo:memo];
25 | }
26 |
27 | - (NSArray *)filter:(BOOL (^)(id, NSUInteger))block {
28 | return [self filteredArrayUsingBlock:block];
29 | }
30 |
31 | - (NSArray *)reject:(BOOL (^)(id, NSUInteger))block {
32 | return [self rejectedArrayUsingBlock:block];
33 | }
34 |
35 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSMutableArray/NSMutableArray+OVSorting.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSMutableArray+Sorting.m
3 | // Overline
4 | //
5 | // Created by Hari Karam Singh on 06/08/2013.
6 | // Copyright (c) 2013 Overline. All rights reserved.
7 | //
8 |
9 | #import "NSMutableArray+OVSorting.h"
10 |
11 | @implementation NSMutableArray (Sorting)
12 |
13 | - (void)sortDescending:(BOOL)shouldBeDescending
14 | {
15 |
16 | [self sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
17 | NSComparisonResult res = [obj1 compare:obj2];
18 |
19 | if (shouldBeDescending) {
20 | if (res == NSOrderedAscending) res = NSOrderedDescending;
21 | else if (res == NSOrderedDescending) res = NSOrderedAscending;
22 | }
23 |
24 | return res;
25 | }];
26 | }
27 |
28 |
29 | - (void)sortAsc
30 | {
31 | [self sortDescending:NO];
32 | }
33 |
34 |
35 | - (void)sortDesc
36 | {
37 | [self sortDescending:YES];
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/Overline/Over/NSDateFormatter/NSDateFormatter+OVShorthand.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/03/28.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSDateFormatter+OVShorthand.h"
9 |
10 |
11 | @implementation NSDateFormatter (OVShorthand)
12 | + (instancetype)dateFormatterWithCalendarIndentifiter:(NSString *)calendar
13 | localeIdentifiter:(NSString *)locale
14 | timeZoneAbbreviation:(NSString *)timeZone {
15 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
16 | formatter.calendar = [[NSCalendar alloc] initWithCalendarIdentifier:calendar];
17 | formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:locale];
18 | formatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:timeZone];
19 | return formatter;
20 | }
21 |
22 | + (instancetype)userDefaultFormatter {
23 | return [[NSDateFormatter alloc] init];
24 | }
25 | @end
--------------------------------------------------------------------------------
/OverlineTests/NSArray/NSArray+ReverseTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSArray+ReverseTest.m
3 | // Copyright 2013 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: kazuma.ukyo
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 | #import "NSArray+OVReverse.h"
12 |
13 | @interface NSArray_ReverseTest : SenTestCase
14 | {
15 |
16 | }
17 | @end
18 |
19 | @implementation NSArray_ReverseTest
20 |
21 | - (void)testReverse
22 | {
23 | assertThat([(@[@1, @2, @3]) reverse], equalTo(@[@3, @2, @1]));
24 | }
25 |
26 | - (void)testReversedArray
27 | {
28 | assertThat([(@[@1, @2, @3]) reversedArray], equalTo(@[@3, @2, @1]));
29 | }
30 |
31 | - (void)testObjectAtReversedIndex
32 | {
33 | assertThat([(@[@1, @2, @3]) objectAtReversedIndex:0], equalTo(@3));
34 | assertThat([(@[@1, @2, @3]) objectAtReversedIndex:1], equalTo(@2));
35 | assertThat([(@[@1, @2, @3]) objectAtReversedIndex:2], equalTo(@1));
36 | }
37 | @end
38 |
--------------------------------------------------------------------------------
/OverlineTests/NSArray/NSArray+DifferenceTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSArray+DifferenceTest.m
3 | // Copyright 2013 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: kazuma.ukyo
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 | #import "NSArray+OVDifference.h"
12 |
13 | @interface NSArray_DifferenceTest : SenTestCase
14 | {
15 |
16 | }
17 | @end
18 |
19 | @implementation NSArray_DifferenceTest
20 |
21 | - (void)testDifference
22 | {
23 | NSArray *left = @[@1, @2, @3, @4];
24 | NSArray *right = @[@1, @2, @5, @6];
25 | NSArray *diff = [left difference:right];
26 |
27 | assertThat(diff, equalTo(@[@3, @4, @5, @6]));
28 | }
29 |
30 | - (void)testUnionise
31 | {
32 | NSArray *left = @[@1, @2, @3, @4];
33 | NSArray *right = @[@1, @2, @4, @5, @6];
34 |
35 | NSArray *unionised = [left unionise:right];
36 |
37 | assertThat(unionised, equalTo(@[@1, @2, @3, @4, @5, @6]));
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVSorting.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+Sorting.m
3 | // Overline
4 | //
5 | // Created by Hari Karam Singh on 06/08/2013.
6 | // Copyright (c) 2013 Overline. All rights reserved.
7 | //
8 |
9 | #import "NSArray+OVSorting.h"
10 |
11 | @implementation NSArray (Sorting)
12 |
13 | - (NSArray *)arraySortedDescending:(BOOL)shouldBeDescending
14 | {
15 | return [self sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
16 | NSComparisonResult res = [obj1 compare:obj2];
17 |
18 | if (shouldBeDescending) {
19 | if (res == NSOrderedAscending) res = NSOrderedDescending;
20 | else if (res == NSOrderedDescending) res = NSOrderedAscending;
21 | }
22 |
23 | return res;
24 | }];
25 | }
26 |
27 |
28 | - (NSArray *)arraySortedAsc
29 | {
30 | return [self arraySortedDescending:NO];
31 | }
32 |
33 |
34 | - (NSArray *)arraySortedDesc
35 | {
36 | return [self arraySortedDescending:YES];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/Overline/UIKit/UIImage/UIImage+OVTransforms.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+OVTransforms.h
3 | // Lab-VC-Transitions
4 | //
5 | // Created by Hari Karam Singh on 24/05/2014.
6 | // Copyright (c) 2014 Air Craft. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIImage (OVTransforms)
12 |
13 | /** Returns a new image which is this one rotated by the specified angle. NOT THREAD SAFE: Call form the main thread only */
14 | - (UIImage *)imageRotatedByRadians:(CGFloat)radians;
15 |
16 | /** Convenience method for degree rotations. See imageRotatedByRadians: */
17 | - (UIImage *)imageRotatedByDegrees:(CGFloat)degrees;
18 |
19 | /** Mirror image reflected horizontally (around the y-axis) */
20 | - (UIImage *)imageReflectedHorizontally;
21 |
22 | /** Mirror image reflected vertically (around the x-axis) */
23 | - (UIImage *)imageReflectedVertically;
24 |
25 | /**
26 | Programatically selectable reflection for none, one or both axes
27 | */
28 | - (UIImage *)imageReflectedHorizontally:(BOOL)doHoriontal vertically:(BOOL)doVertical;
29 |
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/OverlineTests/NSString/NSString+HashTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSString+HashTest.m
3 | // Copyright 2012 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSString+OVHash.h"
13 |
14 | @interface NSString_HashTest : SenTestCase
15 | {
16 |
17 | }
18 | @end
19 |
20 | @implementation NSString_HashTest
21 |
22 | - (void)testSha256 {
23 | assertThat([@"hoge" sha256], equalTo(@"ecb666d778725ec97307044d642bf4d160aabb76f56c0069c71ea25b1e926825"));
24 | }
25 |
26 | - (void)testStringByHashingSha256 {
27 | assertThat([@"hoge" stringByHashingSha256], equalTo(@"ecb666d778725ec97307044d642bf4d160aabb76f56c0069c71ea25b1e926825"));
28 | }
29 |
30 | - (void)testMD5 {
31 | assertThat([@"hoge" md5], equalTo(@"ea703e7aa1efda0064eaa507d9e8ab7e"));
32 | }
33 |
34 | - (void)testStringByHashingMD5 {
35 | assertThat([@"hoge" stringByHashingMD5], equalTo(@"ea703e7aa1efda0064eaa507d9e8ab7e"));
36 | }
37 |
38 | @end
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 KAZUMA Ukyo ( http://www.yaakaito.org )
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/Overline/Over/NSDictionary/NSDictionary+OVPath.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/01/10.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSDictionary+OVPath.h"
9 | #import "NSArray+OVSubArray.h"
10 | #import "NSObject+Equals.h"
11 |
12 |
13 | @implementation NSDictionary (OVPath)
14 | - (id)objectForPath:(NSString *)path {
15 | return [[self class] objectForPathComponents:[path componentsSeparatedByString:@"."] dictionary:self];
16 | }
17 |
18 | + (id)objectForPathComponents:(NSArray *)components dictionary:(NSDictionary *)dictionary {
19 |
20 | if ([components count] == 1) {
21 | return [dictionary objectForKey:components[0]];
22 | }
23 | else {
24 | NSDictionary *next = [dictionary objectForKey:components[0]];
25 | if (next == nil || [next isNullObject]) {
26 | return nil;
27 | }
28 | return [[self class] objectForPathComponents:[components subarrayFromIndex:1]
29 | dictionary:next];
30 | }
31 |
32 | }
33 | @end
--------------------------------------------------------------------------------
/OverlineTests/NSString/NSString+JSONTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSString+JSONTest.m
3 | // Copyright 2013 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSString+OVJSON.h"
13 |
14 | @interface NSString_JSONTest : SenTestCase
15 | {
16 |
17 | }
18 | @end
19 |
20 | @implementation NSString_JSONTest
21 |
22 | - (void)testJSON {
23 | NSString *JSONString = @"{\"hoge\" : \"fuga\" }";
24 | id json = [JSONString JSON];
25 |
26 | assertThat(json, equalTo(@{ @"hoge" : @"fuga"}));
27 |
28 | JSONString = @"{\"}";
29 | json = [JSONString JSON];
30 |
31 | assertThat(json, equalTo(nil));
32 | }
33 |
34 | - (void)testJsonObject {
35 | NSString *JSONString = @"{\"hoge\" : \"fuga\" }";
36 | id json = [JSONString jsonObject];
37 |
38 | assertThat(json, equalTo(@{ @"hoge" : @"fuga"}));
39 |
40 | JSONString = @"{\"}";
41 | json = [JSONString jsonObject];
42 |
43 | assertThat(json, equalTo(nil));
44 | }
45 | @end
46 |
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVDifference.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 2/8/13.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSArray+OVDifference.h"
9 |
10 |
11 | @implementation NSArray (OVDifference)
12 |
13 | - (NSArray *)difference:(NSArray *)array {
14 | return [self arrayDifferenceWithArray:array];
15 | }
16 |
17 | - (NSArray *)arrayDifferenceWithArray:(NSArray *)array {
18 | NSMutableOrderedSet *all = [NSMutableOrderedSet orderedSetWithArray:[self arrayByAddingObjectsFromArray:array]];
19 | NSMutableOrderedSet *dup = [NSMutableOrderedSet orderedSetWithArray:self];
20 | [dup intersectOrderedSet:[NSOrderedSet orderedSetWithArray:array]];
21 | [all minusOrderedSet:dup];
22 | return [all array];
23 | }
24 |
25 | - (NSArray *)unionise:(NSArray *)array {
26 | return [self arrayByUnionisingArray:array];
27 | }
28 |
29 | - (NSArray *)arrayByUnionisingArray:(NSArray *)array {
30 | NSMutableOrderedSet *base = [NSMutableOrderedSet orderedSetWithArray:self];
31 | [base unionOrderedSet:[NSOrderedSet orderedSetWithArray:array]];
32 | return [base array];
33 | }
34 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSURL/NSURL+OVDirectories.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @interface NSURL (OVDirectories)
4 |
5 |
6 | /** Returns an NSURL representing the first path found matching the specified constants or nil if none */
7 | + (NSURL *)URLForDirectory:(NSSearchPathDirectory)directoryConstant domainMask:(NSSearchPathDomainMask)domainMask;
8 |
9 | /** Returns the application support directory with the app's bundle id appended. As recommended in the Fil System Programming Guide */
10 | + (NSURL *)URLForApplicationSupportDataDirectory;
11 |
12 | /** Append a subfolder/file path onto the app data directory */
13 | + (NSURL *)URLForApplicationSupportWithAppendedPath:(NSString *)pathToAppend;
14 |
15 | /** Returns the user directory */
16 | + (NSURL *)URLForUserDirectory;
17 |
18 | /** Append a subfolder/file path onto the user directory */
19 | + (NSURL *)URLForUserDirectoryWithAppendedPath:(NSString *)pathToAppend;
20 |
21 |
22 | /** Returns the user's document directory */
23 | + (NSURL *)URLForDocumentDirectory;
24 |
25 | /** Append a subfolder/file path onto the user's document directory */
26 | + (NSURL *)URLForDocumentDirectoryWithAppendedPath:(NSString *)pathToAppend;
27 |
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVInitialize.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 2/8/13.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSArray+OVInitialize.h"
9 | #import "NSArray+OVReverse.h"
10 |
11 |
12 | @implementation NSArray (OVInitialize)
13 |
14 | + (instancetype)_arrayWithRangeFrom:(NSInteger)from to:(NSInteger)to step:(NSUInteger)step reverse:(BOOL)reverse {
15 | NSMutableArray *array = [NSMutableArray array];
16 | for (NSInteger i = from; i < to; i += step) {
17 | [array addObject:[NSNumber numberWithInteger:i]];
18 | }
19 |
20 | if (reverse) {
21 | return [array reversedArray];
22 | }
23 |
24 | return [NSArray arrayWithArray:array];
25 | }
26 |
27 | + (instancetype)arrayWithRangeFrom:(NSInteger)from to:(NSInteger)to {
28 | return [self.class arrayWithRangeFrom:from to:to step:1];
29 | }
30 |
31 | + (instancetype)arrayWithRangeFrom:(NSInteger)from to:(NSInteger)to step:(NSUInteger)step {
32 | if (from > to) {
33 | // reverse
34 | return [self.class _arrayWithRangeFrom:to + 1 to:from + 1 step:step reverse:YES];
35 | }
36 |
37 | return [self.class _arrayWithRangeFrom:from to:to step:step reverse:NO];
38 | }
39 |
40 |
41 | @end
--------------------------------------------------------------------------------
/Overline/UIKit/UIImage/UIImage+OVGradients.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+OVGradients.h
3 | // Lab-VC-Transitions
4 | //
5 | // Created by Hari Karam Singh on 23/05/2014.
6 | // Copyright (c) 2014 Air Craft. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIImage (OVGradients)
12 |
13 |
14 | /**
15 | Draws a gradient in the rectangle defined by `size` along the line defined by startPoint/endPoint.
16 |
17 | @param locationsColorsDict Dict whose keys are NSNumbers with color position (0, 1 represent the start, end point colours but you arent limited to these) and whose values are the UIColors themselves.
18 | */
19 | + (UIImage *)gradientImageWithSize:(CGSize)size colors:(NSDictionary *)locationsColorsDict startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint;
20 |
21 | /** Convenience method for a gradient along the horizontal axis with locations 0,1 pinned to the left/right edges */
22 | + (UIImage *)horizontalGradientImageWithSize:(CGSize)size colors:(NSDictionary *)locationsColorsDict;
23 |
24 | /** Convenience method for a gradient along the horizontal axis with locations 0,1 pinned to the top/bottom edges */
25 | + (UIImage *)verticalGradientImageWithSize:(CGSize)size colors:(NSDictionary *)locationsColorsDict;
26 |
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/Overline/Over/NSDictionary/NSDictionary+OVSelector.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/03/22.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSDictionary (OVSelector)
11 | - (id)objectForKey:(id)aKey transformBlock:(id (^)(id obj))block;
12 | - (NSNumber *)numberForKey:(id)aKey;
13 | - (NSString *)stringForKey:(id)aKey;
14 | - (NSArray *)arrayForKey:(id)aKey;
15 | - (NSDictionary *)dictionaryForKey:(id)aKey;
16 | - (NSDate *)dateForKey:(id)aKey;
17 | - (NSDate *)dateForKey:(id)aKey usingFormat:(NSString *)formatString;
18 | - (NSDate *)since1970DateForKey:(NSString *)aKey;
19 | - (NSDate *)timestampForKey:(NSString *)aKey;
20 | - (NSNumber *)boolObjectForKey:(NSString *)aKey withTrueValue:(id)value;
21 | - (BOOL)boolForKey:(id)aKey withTureValue:(id)value;
22 | - (BOOL)boolForKey:(id)aKey;
23 | - (int)intForKey:(id)aKey;
24 | - (NSInteger)integerForKey:(id)aKey;
25 | - (unsigned int)unsignedIntForKey:(id)aKey;
26 | - (NSUInteger)unsignedIntegerForKey:(id)aKey;
27 | - (long)longForKey:(id)aKey;
28 | - (unsigned long)unsignedLongForKey:(id)aKey;
29 | - (long long)longLongForKey:(id)aKey;
30 | - (unsigned long long)unsignedLongLongForKey:(id)aKey;
31 | - (double)doubleForKey:(id)aKey;
32 | - (float)floatForKey:(id)aKey;
33 | @end
--------------------------------------------------------------------------------
/Overline/UIKit/UIBezierPath/UIBezierPath+OVShapes.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIBezierPath+OVShapes.m
3 | // AC-Sabre
4 | //
5 | // Created by Hari Karam Singh on 05/06/2014.
6 | //
7 | //
8 |
9 | #import
10 | #import "UIBezierPath+OVShapes.h"
11 |
12 | @implementation UIBezierPath (OVShapes)
13 |
14 | + (instancetype)bezierPathEquilaterialTriangleWithSideLength:(CGFloat)sideLength rotation:(CGFloat)rotation
15 | {
16 | // Let's get the points based on having it centered (for the rotation)
17 | const CGFloat deg30 = M_PI/6.;
18 | const CGFloat L_2 = 0.5 * sideLength;
19 | CGPoint top = {0, L_2 / -cos(deg30)};
20 | CGPoint left = {-L_2, tan(deg30) * L_2};
21 | CGPoint right = {+L_2, tan(deg30) * L_2};
22 |
23 | UIBezierPath *path = [self bezierPath];
24 | [path moveToPoint:top];
25 | [path addLineToPoint:left];
26 | [path addLineToPoint:right];
27 | [path closePath];
28 |
29 | // Now rotate...
30 | if (rotation) {
31 | [path applyTransform:CGAffineTransformMakeRotation(rotation)];
32 | }
33 |
34 | // And adjust to be in the positive quadrant starting at 0,0
35 | CGAffineTransform tx = CGAffineTransformMakeTranslation(-path.bounds.origin.x, -path.bounds.origin.y);
36 | [path applyTransform:tx];
37 |
38 | return path;
39 | }
40 |
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/Overline/UIKit/UIColor/UIColor+OVColorAdjust.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIColor+OVColorAdjust.h
3 | // Lab-VC-Transitions
4 | //
5 | // Created by Hari Karam Singh on 23/05/2014.
6 | // Copyright (c) 2014 Air Craft. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIColor (OVColorAdjust)
12 |
13 | /**
14 | Return a new UIColor with each parameter x mapped to f(x) = Kx + N. Hue is wrapped, the others' clamped to 0..1.
15 | */
16 | - (UIColor *)colorAugmentedByHueFactor:(CGFloat)hueK
17 | saturationFactor:(CGFloat)satK
18 | brightnessFactor:(CGFloat)brightK
19 | alphaFactor:(CGFloat)alphaK
20 | hueShift:(CGFloat)hueN
21 | saturationShift:(CGFloat)satN
22 | brightnessShift:(CGFloat)brightN
23 | alphaShift:(CGFloat)alphaN;
24 |
25 | //---------------------------------------------------------------------
26 |
27 | /** Convenience method for doing just the brightness. [0, 1) = dim, [1, inf) = brighten; */
28 | - (UIColor *)colorWithBrightenessScaledBy:(CGFloat)factor;
29 |
30 | /** Convenience method for doing just the saturation. [0, 1) = desat, [1, inf) = saturate; */
31 | - (UIColor *)colorWithSaturationScaledBy:(CGFloat)factor;
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/Overline/Over/NSNumber/NSNumber+OVEquals.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by kazuma.ukyo on 12/27/12.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSNumber+OVEquals.h"
9 |
10 |
11 | @implementation NSNumber (OVEquals)
12 | - (BOOL)isEqualToInt:(int)value {
13 | return [self intValue] == value;
14 | }
15 |
16 | - (BOOL)isEqualToInteger:(NSInteger)value {
17 | return [self integerValue] == value;
18 | }
19 |
20 | - (BOOL)isEqualToUnsignedInt:(unsigned int)value {
21 | return [self unsignedIntValue] == value;
22 | }
23 |
24 | - (BOOL)isEqualToUnsignedInteger:(NSUInteger)value {
25 | return [self unsignedIntegerValue] == value;
26 | }
27 |
28 | - (BOOL)isEqualToLong:(long)value {
29 | return [self longValue] == value;
30 | }
31 |
32 | - (BOOL)isEqualToLongLong:(long long int)value {
33 | return [self longLongValue] == value;
34 | }
35 |
36 | - (BOOL)isEqualToUnsignedLong:(unsigned long)value {
37 | return [self unsignedLongValue] == value;
38 | }
39 |
40 | - (BOOL)isEqualToUnsignedLongLong:(unsigned long long)value {
41 | return [self unsignedLongLongValue] == value;
42 | }
43 |
44 | - (BOOL)isEqualToDouble:(double)value {
45 | return [self doubleValue] == value;
46 | }
47 |
48 | - (BOOL)isEqualToFloat:(float)value {
49 | return [self floatValue] == value;
50 | }
51 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSDictionary/NSDictionary+OVEnumeration.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/24.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSDictionary (OVEnumeration)
11 |
12 | - (NSDictionary *)mappedDictionaryUsingBlock:(id (^)(id obj, NSString *key))block;
13 | - (NSArray *)arrayMap:(id (^)(id obj, NSString *key))block;
14 | - (NSArray *)mappedArrayUsingBlock:(id (^)(id obj, NSString *key))block;
15 | - (NSDictionary *)filterKey:(BOOL (^)(NSString *key))block;
16 | - (NSDictionary *)dictionaryFilteredByKeyUsingBlock:(BOOL (^)(NSString *key))block;
17 | - (NSDictionary *)rejectKey:(BOOL (^)(NSString *key))block;
18 | - (NSDictionary *)dictionaryRejectedByKeyUsingBlock:(BOOL (^)(NSString *key))block;
19 | - (NSDictionary *)filterObject:(BOOL (^)(id obj))block;
20 | - (NSDictionary *)dictionaryFilteredByObjectUsingBlock:(BOOL (^)(id obj))block;
21 | - (NSDictionary *)rejectObject:(BOOL (^)(id obj))block;
22 | - (NSDictionary *)dictionaryRejectedByObjectUsingBlock:(BOOL (^)(id obj))block;
23 | - (NSDictionary *)merge:(NSDictionary *)dictionary;
24 | - (NSDictionary *)dictionaryByMergingDictionary:(NSDictionary *)dictionary;
25 | - (id)reducedObjectUsingBlock:(id (^)(id memo, id obj, NSString *key))block memo:(id)memo;
26 | - (NSString *)queryString;
27 | - (NSString *)stringByFormattingQuery;
28 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVSubArray.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/01/10.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSArray+OVSubArray.h"
9 |
10 |
11 | @implementation NSArray (OVSubArray)
12 |
13 | - (NSArray *)subarrayFromIndex:(NSUInteger)index {
14 | return [self subarrayFromIndex:index length:[self count] - index];
15 | }
16 |
17 | - (NSArray *)subarrayFromIndex:(NSUInteger)index length:(NSUInteger)length {
18 | return [self subarrayWithRange:NSMakeRange(index, length)];
19 | }
20 |
21 | - (NSArray *)subarrayToIndex:(NSUInteger)index {
22 | return [self subarrayWithRange:NSMakeRange(0, index+1)];
23 | }
24 |
25 | - (NSArray *)uniqueObjects {
26 | return [[NSOrderedSet orderedSetWithArray:self] array];
27 | }
28 |
29 | - (NSArray *)uniqueObjectsUsingEqualsBlock:(BOOL (^)(id, id))block {
30 | NSMutableArray *unique = [NSMutableArray array];
31 | [self enumerateObjectsUsingBlock:^(id right, NSUInteger idx, BOOL *stop) {
32 | __block BOOL ignore = NO;
33 | [unique enumerateObjectsUsingBlock:^(id left, NSUInteger idx, BOOL *stop) {
34 | if ((ignore = block(left, right))){
35 | *stop = YES;
36 | }
37 | }];
38 | if (!ignore) {
39 | [unique addObject:right];
40 | }
41 | }];
42 | return [NSArray arrayWithArray:unique];
43 | }
44 |
45 | @end
--------------------------------------------------------------------------------
/Overline/UIKit/UIView/UIView+OVSnapshot.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+OVSnapshot.m
3 | // Overline
4 | //
5 | // Created by Hari Karam Singh on 22/05/2014.
6 | // Copyright (c) 2014 Air Craft Media Ltd. MIT License.
7 | //
8 |
9 | #import "UIView+OVSnapshot.h"
10 |
11 | @implementation UIView (OVSnapshot)
12 |
13 | - (UIImage *)renderAsImage
14 | {
15 | UIImage *snapshotImage;
16 | UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 0.0);
17 | {
18 | [self.layer.presentationLayer renderInContext:UIGraphicsGetCurrentContext()];
19 | snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
20 | }
21 | UIGraphicsEndImageContext();
22 |
23 | return snapshotImage;
24 | }
25 |
26 | //---------------------------------------------------------------------
27 |
28 | - (UIImage *)snapshotImageAfterScreenUpdates:(BOOL)afterUpdates
29 | {
30 | if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
31 | return [self renderAsImage];
32 | } else {
33 |
34 | UIImage *snapshotImage;
35 | UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 0.0);
36 | {
37 | [self drawViewHierarchyInRect:self.bounds afterScreenUpdates:afterUpdates];
38 | snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
39 | }
40 | UIGraphicsEndImageContext();
41 |
42 | return snapshotImage;
43 | }
44 | }
45 | @end
46 |
--------------------------------------------------------------------------------
/OverlineTests/NSDictionary/NSDictionary+PathTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSDictionary+PathTest.m
3 | // Copyright 2013 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSDictionary+OVPath.h"
13 |
14 | @interface NSDictionary_PathTest : SenTestCase
15 | {
16 |
17 | }
18 | @end
19 |
20 | @implementation NSDictionary_PathTest
21 |
22 | - (void)testObjectForPath
23 | {
24 | NSString *result = [@{
25 | @"hoge" : @"fuga"
26 | } objectForPath:@"hoge"];
27 | assertThat(result, equalTo(@"fuga"));
28 |
29 | result = [@{
30 | @"p1" : @{
31 | @"p2" : @{
32 | @"p3" : @"value"
33 | }
34 | }
35 | } objectForPath:@"p1.p2.p3"];
36 | assertThat(result, equalTo(@"value"));
37 |
38 | result = [@{
39 | @"p1" : @{
40 | @"p2" : @{
41 | @"p3" : @"value"
42 | }
43 | }
44 | } objectForPath:@"p1.p2.p4"];
45 | assertThat(result, equalTo(nil));
46 |
47 | result = [@{
48 | @"p1" : @{
49 | @"p2" : @{
50 | @"p3" : @"value"
51 | }
52 | }
53 | } objectForPath:@"p1.p5.p4"];
54 | assertThat(result, equalTo(nil));
55 | }
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/Header/Overline+BlocksKit.h:
--------------------------------------------------------------------------------
1 | //
2 | // Overline.h
3 | // Overline
4 | //
5 | // Created by yaakaito on 12/12/01.
6 | // Copyright (c) 2012年 yaakaito. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "NSArray+OVShorthand.h"
12 | #import "NSArray+OVEnumeration.h"
13 | #import "NSArray+OVRandom.h"
14 | #import "NSArray+OVSelector.h"
15 | #import "NSArray+OVSubArray.h"
16 | #import "NSArray+OVDifference.h"
17 | #import "NSArray+OVInitialize.h"
18 | #import "NSArray+OVReverse.h"
19 | #import "NSArray+OVSorting.h"
20 |
21 | #import "NSLayoutConstraint+OVConstructor.h"
22 |
23 | #import "NSMutableArray+OVShorthand.h"
24 | #import "NSMutableArray+OVSorting.h"
25 |
26 | #import "NSDate+OVComponents.h"
27 |
28 | #import "NSDictionary+OVEnumeration.h"
29 | #import "NSDictionary+OVPath.h"
30 | #import "NSDictionary+OVSelector.h"
31 |
32 | #import "NSString+OVHash.h"
33 | #import "NSString+OVShorthand.h"
34 | #import "NSString+OVComponents.h"
35 | #import "NSString+OVRegularExpression.h"
36 | #import "NSString+OVURLEncode.h"
37 | #import "NSString+OVBase64Encode.h"
38 | #import "NSString+OVJSON.h"
39 |
40 | #import "NSSet+OVEnumeration.h"
41 |
42 | #import "NSData+OVBase64Encode.h"
43 |
44 | #import "NSBundle+OVShorthand.h"
45 |
46 | #import "NSURL+OVComponents.h"
47 | #import "NSURL+OVDirectories.h"
48 |
49 | #import "NSNumber+OVEquals.h"
50 |
51 | #import "NSObject+Equals.h"
52 |
53 | #ifdef OV_USE_NATURAL_NULL
54 | #import "NSNull+Natural.h"
55 | #endif
56 |
57 |
--------------------------------------------------------------------------------
/Overline/Over/NSSet/NSSet+OVEnumeration.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/01/04.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSSet+OVEnumeration.h"
9 |
10 |
11 | @implementation NSSet (OVEnumeration)
12 |
13 | - (NSSet *)mappedSetUsingBlock:(id (^)(id))block {
14 | NSMutableSet *result = [NSMutableSet set];
15 | [self enumerateObjectsUsingBlock:^(id obj, BOOL *stop) {
16 | id o = block(obj);
17 | if (o) {
18 | [result addObject:o];
19 | }
20 | }];
21 | return result;
22 | }
23 |
24 | - (id)reducedObjectByBlock:(id (^)(id, id))block memo:(id)memo {
25 | __block id reducedObject = memo;
26 | [self enumerateObjectsUsingBlock:^(id obj, BOOL *stop) {
27 | reducedObject = block(reducedObject, obj);
28 | }];
29 | return reducedObject;
30 | }
31 |
32 | - (NSSet *)filteredSetUsingBlock:(BOOL (^)(id))block opposite:(BOOL)opposite {
33 | NSMutableSet *filteredSet = [NSMutableSet set];
34 | [self enumerateObjectsUsingBlock:^(id obj, BOOL *stop) {
35 | BOOL r = block(obj);
36 | if (r == !opposite) {
37 | [filteredSet addObject:obj];
38 | }
39 | }];
40 | return filteredSet;
41 | }
42 |
43 | - (NSSet *)filteredSetUsingBlock:(BOOL (^)(id))block {
44 | return [self filteredSetUsingBlock:block opposite:NO];
45 | }
46 |
47 | - (NSSet *)rejectedSetUsingBlock:(BOOL (^)(id))block {
48 | return [self filteredSetUsingBlock:block opposite:YES];
49 | }
50 | @end
--------------------------------------------------------------------------------
/OverlineTests/NSArray/NSArray+RandomTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSArray+RandomTest.m
3 | // Copyright 2012 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSArray+OVRandom.h"
13 |
14 | @interface NSArray_RandomTest : SenTestCase
15 | {
16 |
17 | }
18 | @end
19 |
20 | @implementation NSArray_RandomTest
21 |
22 |
23 | - (void)testShuffle {
24 | NSArray *shuffled = [@[@1,@2,@3,@4,@5,@6] shuffle];
25 | assertThat(@([shuffled count]), equalTo(@6));
26 | [SenTestLog testLogWithFormat:@"%@", shuffled];
27 | }
28 |
29 | - (void)testShuffledArray {
30 | NSArray *shuffled = [@[@1,@2,@3,@4,@5,@6] shuffledArray];
31 | assertThat(@([shuffled count]), equalTo(@6));
32 | [SenTestLog testLogWithFormat:@"%@", shuffled];
33 | }
34 |
35 | - (void)testAnyObject {
36 | NSArray *array = @[@1, @2, @3];
37 |
38 | assertThatBool([array indexOfObject:[array anyObject]] != NSNotFound, equalToBool(YES));
39 | assertThatBool([array indexOfObject:[array anyObject]] != NSNotFound, equalToBool(YES));
40 | assertThatBool([array indexOfObject:[array anyObject]] != NSNotFound, equalToBool(YES));
41 | assertThatBool([array indexOfObject:[array anyObject]] != NSNotFound, equalToBool(YES));
42 | }
43 |
44 | - (void)testAnyObjectWithEmptyArray {
45 | NSArray *array = @[];
46 |
47 | assertThatBool([array anyObject] == nil, equalToBool(YES));
48 | }
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/OverlineTests/NSArray/NSArray+InitializeTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSArray+InitializeTest.m
3 | // Copyright 2013 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: kazuma.ukyo
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 | #import "NSArray+OVInitialize.h"
12 |
13 | @interface NSArray_InitializeTest : SenTestCase
14 | {
15 |
16 | }
17 | @end
18 |
19 | @implementation NSArray_InitializeTest
20 |
21 | - (void)testArrayWithRangeFromTo
22 | {
23 | assertThat([NSArray arrayWithRangeFrom:0 to:10], equalTo(@[@0, @1, @2, @3, @4, @5, @6, @7, @8, @9]));
24 | assertThat([NSArray arrayWithRangeFrom:-10 to:10], equalTo(@[@-10, @-9, @-8, @-7, @-6, @-5, @-4, @-3, @-2, @-1, @0, @1, @2, @3, @4, @5, @6, @7, @8, @9]));
25 | assertThat([NSArray arrayWithRangeFrom:0 to:-10], equalTo(@[@0, @-1, @-2, @-3, @-4, @-5, @-6, @-7, @-8, @-9]));
26 | assertThat([NSArray arrayWithRangeFrom:-5 to:0], equalTo(@[@-5, @-4, @-3, @-2, @-1]));
27 | assertThat([NSArray arrayWithRangeFrom:-5 to:-10], equalTo(@[@-5, @-6, @-7, @-8, @-9]));
28 | }
29 |
30 | - (void)testArrayWithRangeFromToStep
31 | {
32 | assertThat([NSArray arrayWithRangeFrom:0 to:10 step:2], equalTo(@[@0, @2, @4, @6, @8]));
33 | assertThat([NSArray arrayWithRangeFrom:-10 to:0 step:2], equalTo(@[@-10, @-8, @-6, @-4, @-2]));
34 | assertThat([NSArray arrayWithRangeFrom:-5 to:0 step:2], equalTo(@[@-5, @-3, @-1]));
35 | assertThat([NSArray arrayWithRangeFrom:-5 to:-15 step:3], equalTo(@[@-5, @-8, @-11, @-14]));
36 | }
37 | @end
38 |
--------------------------------------------------------------------------------
/Header/Overline.h:
--------------------------------------------------------------------------------
1 | //
2 | // Overline.h
3 | // Overline
4 | //
5 | // Created by yaakaito on 12/12/01.
6 | // Copyright (c) 2012年 yaakaito. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "NSArray+OVShorthand.h"
12 | #import "NSArray+OVEnumeration.h"
13 | #import "NSArray+OVRandom.h"
14 | #import "NSArray+OVSelector.h"
15 | #import "NSArray+OVSubArray.h"
16 | #import "NSArray+OVShorthand.h"
17 | #import "NSArray+OVDifference.h"
18 | #import "NSArray+OVInitialize.h"
19 | #import "NSArray+OVReverse.h"
20 |
21 | #import "NSLayoutConstraint+OVConstructors.h"
22 |
23 | #import "NSMutableArray+OVShorthand.h"
24 | #import "NSMutableArray+OVSorting.h"
25 |
26 | #import "NSDate+OVComponents.h"
27 |
28 | #import "NSDictionary+OVEnumeration.h"
29 | #import "NSDictionary+OVPath.h"
30 | #import "NSDictionary+OVSelector.h"
31 |
32 | #import "NSMutableDictionary+OVShorthand.h"
33 |
34 | #import "NSString+OVHash.h"
35 | #import "NSString+OVShorthand.h"
36 | #import "NSString+OVComponents.h"
37 | #import "NSString+OVRegularExpression.h"
38 | #import "NSString+OVURLEncode.h"
39 | #import "NSString+OVBase64Encode.h"
40 | #import "NSString+OVJSON.h"
41 |
42 | #import "NSSet+OVEnumeration.h"
43 |
44 | #import "NSData+OVBase64Encode.h"
45 |
46 | #import "NSBundle+OVShorthand.h"
47 |
48 | #import "NSURL+OVComponents.h"
49 | #import "NSURL+OVDirectories.h"
50 |
51 | #import "NSNumber+OVEquals.h"
52 |
53 | #import "NSObject+Equals.h"
54 |
55 | #ifdef OV_USE_NATURAL_NULL
56 | #import "NSNull+Natural.h"
57 | #endif
58 |
59 | #import "NSArray+OVCore.h"
60 | #import "NSDictionary+OVCore.h"
61 | #import "NSSet+OVCore.h"
62 |
--------------------------------------------------------------------------------
/Overline/UIKit/UIColor/UIColor+OVRandom.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIColor+OVRandom.m
3 | // AC-Sabre
4 | //
5 | // Created by Hari Karam Singh on 04/06/2014.
6 | //
7 | //
8 |
9 | #import "UIColor+OVRandom.h"
10 |
11 | @implementation UIColor (OVRandom)
12 |
13 | + (UIColor *)randomColor
14 | {
15 | return [self randomColorWithAlpha:1.0];
16 | }
17 |
18 | //---------------------------------------------------------------------
19 |
20 | + (UIColor *)randomColorWithAlpha:(CGFloat)alpha
21 | {
22 | CGFloat h = arc4random_uniform(INT32_MAX) / (CGFloat)INT32_MAX;
23 | CGFloat s = arc4random_uniform(INT32_MAX) / (CGFloat)INT32_MAX;
24 | CGFloat b = arc4random_uniform(INT32_MAX) / (CGFloat)INT32_MAX;
25 |
26 | // I believe HSB gives more variety where rgb is skewed towards muted tones
27 | return [UIColor colorWithHue:h saturation:s brightness:b alpha:alpha];
28 | }
29 |
30 | //---------------------------------------------------------------------
31 |
32 | + (UIColor *)randomHue
33 | {
34 | return [self randomHueWithSaturation:1 brightness:1 alpha:1];
35 | }
36 |
37 | //---------------------------------------------------------------------
38 |
39 | + (UIColor *)randomHueWithAlpha:(CGFloat)alpha
40 | {
41 | return [self randomHueWithSaturation:1 brightness:1 alpha:alpha];
42 | }
43 |
44 | //---------------------------------------------------------------------
45 |
46 | + (UIColor *)randomHueWithSaturation:(CGFloat)s brightness:(CGFloat)b alpha:(CGFloat)a
47 | {
48 | CGFloat h = arc4random_uniform(INT32_MAX) / (CGFloat)INT32_MAX;
49 |
50 | return [UIColor colorWithHue:h saturation:s brightness:b alpha:a];
51 | }
52 |
53 |
54 | @end
55 |
--------------------------------------------------------------------------------
/Overline.xcodeproj/xcshareddata/xcschemes/Jenkins.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
9 |
15 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
29 |
30 |
31 |
32 |
33 |
36 |
37 |
39 |
40 |
42 |
43 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/Overline/Over/NSString/NSString+OVRegularExpression.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/16.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import
9 |
10 | @interface NSString (OVRegularExpression)
11 |
12 | - (NSRange)rangeOfFirstMatchInString:(NSString *)string;
13 | - (NSRange)rangeOfFirstMatchInString:(NSString *)string options:(NSRegularExpressionOptions)options;
14 | - (NSArray *)matchesInString:(NSString *)string;
15 | - (NSArray *)matchesInString:(NSString *)string options:(NSRegularExpressionOptions)options;
16 | - (BOOL)testInString:(NSString *)string;
17 | - (BOOL)testInString:(NSString *)string options:(NSRegularExpressionOptions)options;
18 | - (NSString *)replace:(NSString *)regexpPattern newString:(NSString *)string;
19 | - (NSString *)replace:(NSString *)regexpPattern newString:(NSString *)string options:(NSRegularExpressionOptions)options;
20 | - (NSString *)stringByReplacingOccurrencesOfRegExpPattern:(NSString *)regexpPattern withString:(NSString *)string;
21 | - (NSString *)stringByReplacingOccurrencesOfRegExpPattern:(NSString *)regexpPattern withString:(NSString *)string options:(NSRegularExpressionOptions)options;
22 | - (NSString *)replace:(NSString *)regexpPattern withTemplate:(NSString *)aTemplate;
23 | - (NSString *)replace:(NSString *)regexpPattern withTemplate:(NSString *)aTemplate options:(NSRegularExpressionOptions)options;
24 | - (NSString *)stringByReplacingOccurrencesOfRegExpPattern:(NSString *)regexpPattern withTemplate:(NSString *)aTemplate;
25 | - (NSString *)stringByReplacingOccurrencesOfRegExpPattern:(NSString *)regexpPattern withTemplate:(NSString *)aTemplate options:(NSRegularExpressionOptions)options;
26 |
27 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSString/NSString+OVHash.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/25.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSString+OVHash.h"
9 | #import
10 |
11 | @implementation NSString (OVHash)
12 |
13 | - (NSString *)sha256 {
14 | return [self stringByHashingSha256];
15 | }
16 |
17 | - (NSString *)stringByHashingSha256 {
18 | const char *s=[self cStringUsingEncoding:NSASCIIStringEncoding];
19 | NSData *keyData=[NSData dataWithBytes:s length:strlen(s)];
20 |
21 | uint8_t digest[CC_SHA256_DIGEST_LENGTH]={0};
22 | CC_SHA256(keyData.bytes, (CC_LONG)keyData.length, digest);
23 | NSData *out =
24 | [NSData dataWithBytes:digest length:CC_SHA256_DIGEST_LENGTH];
25 | NSString *hash=[out description];
26 | hash = [hash stringByReplacingOccurrencesOfString:@" " withString:@""];
27 | hash = [hash stringByReplacingOccurrencesOfString:@"<" withString:@""];
28 | hash = [hash stringByReplacingOccurrencesOfString:@">" withString:@""];
29 | return hash;
30 |
31 | }
32 |
33 | - (NSString *)md5 {
34 | return [self stringByHashingMD5];
35 | }
36 |
37 | - (NSString *)stringByHashingMD5 {
38 | const char *cStr = [self UTF8String];
39 | unsigned char result[16];
40 | CC_MD5( cStr, (CC_LONG)strlen(cStr), result ); // This is the md5 call
41 | return [NSString stringWithFormat:
42 | @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
43 | result[0], result[1], result[2], result[3],
44 | result[4], result[5], result[6], result[7],
45 | result[8], result[9], result[10], result[11],
46 | result[12], result[13], result[14], result[15]
47 | ];
48 | }
49 | @end
--------------------------------------------------------------------------------
/Overline/Over/OVBase64Encode.h:
--------------------------------------------------------------------------------
1 | //
2 | // OVBase64Encode.h
3 | // Overline
4 | //
5 | // Created by yaakaito on 01/05/13.
6 | // Copyright (c) 2013 __MyCompanyName__. All rights reserved.
7 | //
8 |
9 | // http://stackoverflow.com/questions/392464/any-base64-library-on-iphone-sdk
10 |
11 | #ifndef _OVBase64Encode____FILEEXTENSION___
12 | #define _OVBase64Encode____FILEEXTENSION___
13 |
14 | static const char _base64EncodingTable[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
15 | static const short _base64DecodingTable[256] = {
16 | -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1, -2, -1, -1, -2, -2,
17 | -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
18 | -1, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, 62, -2, -2, -2, 63,
19 | 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -2, -2, -2, -2, -2, -2,
20 | -2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
21 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -2, -2, -2, -2, -2,
22 | -2, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
23 | 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -2, -2, -2, -2, -2,
24 | -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
25 | -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
26 | -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
27 | -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
28 | -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
29 | -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
30 | -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
31 | -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2
32 | };
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/OverlineTests/NSDateFormatter/NSDateFormatter+ShorthandTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSDateFormatter+ShorthandTest.m
3 | // Copyright 2013 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSDateFormatter+OVShorthand.h"
13 |
14 | @interface NSDateFormatter_ShorthandTest : SenTestCase
15 | {
16 |
17 | }
18 | @end
19 |
20 | @implementation NSDateFormatter_ShorthandTest
21 |
22 |
23 | - (void)setUp {
24 | // Run before each test method
25 | }
26 |
27 | - (void)tearDown {
28 | // Run after each test method
29 | }
30 |
31 | - (void)testFormatterWithCalendarLocaleTimezone
32 | {
33 | NSDateFormatter *formatter = [NSDateFormatter dateFormatterWithCalendarIndentifiter:NSGregorianCalendar
34 | localeIdentifiter:@"ja_JP"
35 | timeZoneAbbreviation:@"JST"];
36 | [formatter setDateFormat:@"yyyy/MM/dd HH:mm:ss Z"];
37 | NSDate *date = [NSDate dateWithTimeIntervalSince1970:1360000000];
38 | assertThat([formatter stringFromDate:date], equalTo(@"2013/02/05 02:46:40 +0900"));
39 | }
40 |
41 | - (void)testUserDefaultFormatter
42 | {
43 | NSDateFormatter *formatter1 = [NSDateFormatter userDefaultFormatter];
44 | NSDateFormatter *formatter2 = [[NSDateFormatter alloc] init];
45 | [formatter1 setDateFormat:@"yyyy/MM/dd HH:mm:ss Z"];
46 | [formatter2 setDateFormat:@"yyyy/MM/dd HH:mm:ss Z"];
47 |
48 | NSDate *date = [NSDate dateWithTimeIntervalSince1970:1360000000];
49 |
50 | assertThat([formatter1 stringFromDate:date], equalTo([formatter2 stringFromDate:date]));
51 | }
52 |
53 | @end
54 |
--------------------------------------------------------------------------------
/Overline/UIKit/UIColor/UIColor+OVColorAdjust.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIColor+OVColorAdjust.m
3 | // Lab-VC-Transitions
4 | //
5 | // Created by Hari Karam Singh on 23/05/2014.
6 | // Copyright (c) 2014 Air Craft. All rights reserved.
7 | //
8 |
9 | #import "UIColor+OVColorAdjust.h"
10 |
11 | @implementation UIColor (OVColorAdjust)
12 |
13 | - (UIColor *)colorAugmentedByHueFactor:(CGFloat)hueK saturationFactor:(CGFloat)satK brightnessFactor:(CGFloat)brightK alphaFactor:(CGFloat)alphaK hueShift:(CGFloat)hueN saturationShift:(CGFloat)satN brightnessShift:(CGFloat)brightN alphaShift:(CGFloat)alphaN
14 | {
15 | CGFloat h, s, b, a;
16 | [self getHue:&h saturation:&s brightness:&b alpha:&a];
17 |
18 | h = hueK * h + hueN;
19 | s = satK * s + satN;
20 | b = brightK * b + brightN;
21 | a = alphaK * a + alphaN;
22 |
23 | // wrap h, clamp the others
24 | if (h > 1) h = h - floorf(h);
25 | else if (h < 0) h += floorf(h);
26 | s = MAX(0.0, MIN(1.0, s));
27 | b = MAX(0.0, MIN(1.0, b));
28 | a = MAX(0.0, MIN(1.0, a));
29 |
30 | return [UIColor colorWithHue:h saturation:s brightness:b alpha:a];
31 | }
32 |
33 | //---------------------------------------------------------------------
34 |
35 | - (UIColor *)colorWithBrightenessScaledBy:(CGFloat)factor
36 | {
37 | return [self colorAugmentedByHueFactor:1 saturationFactor:1 brightnessFactor:factor alphaFactor:1 hueShift:0 saturationShift:0 brightnessShift:0 alphaShift:0];
38 | }
39 |
40 | //---------------------------------------------------------------------
41 |
42 | - (UIColor *)colorWithSaturationScaledBy:(CGFloat)factor
43 | {
44 | return [self colorAugmentedByHueFactor:1 saturationFactor:factor brightnessFactor:1 alphaFactor:1 hueShift:0 saturationShift:0 brightnessShift:0 alphaShift:0];
45 | }
46 |
47 |
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/OverlineTests/NSString/NSString+Base64EncodeTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSString+Base64EncodeTest.m
3 | // Copyright 2013 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSString+OVBase64Encode.h"
13 |
14 | @interface NSString_Base64EncodeTest : SenTestCase
15 | {
16 |
17 | }
18 | @end
19 |
20 | @implementation NSString_Base64EncodeTest
21 |
22 | - (void)testEncodeBase64 {
23 | assertThat([@"a" encodeBase64], equalTo(@"YQ=="));
24 | assertThat([@"hogehoge" encodeBase64], equalTo(@"aG9nZWhvZ2U="));
25 | assertThat([@"あいうえお" encodeBase64], equalTo(@"44GC44GE44GG44GI44GK"));
26 | }
27 |
28 | - (void)testStringByEncodingBase64 {
29 | assertThat([@"a" stringByEncodingBase64], equalTo(@"YQ=="));
30 | assertThat([@"hogehoge" stringByEncodingBase64], equalTo(@"aG9nZWhvZ2U="));
31 | assertThat([@"あいうえお" stringByEncodingBase64], equalTo(@"44GC44GE44GG44GI44GK"));
32 | }
33 |
34 | - (void)testDecodeBase64 {
35 | assertThat([@"YQ==" decodeBase64], equalTo(@"a"));
36 | assertThat([@"aG9nZWhvZ2U=" decodeBase64], equalTo(@"hogehoge"));
37 | assertThat([@"44GC44GE44GG44GI44GK" decodeBase64], equalTo(@"あいうえお"));
38 | }
39 |
40 | - (void)testStringByDecodingBase64 {
41 | assertThat([@"YQ==" stringByDecodingBase64], equalTo(@"a"));
42 | assertThat([@"aG9nZWhvZ2U=" stringByDecodingBase64], equalTo(@"hogehoge"));
43 | assertThat([@"44GC44GE44GG44GI44GK" stringByDecodingBase64], equalTo(@"あいうえお"));
44 | }
45 |
46 | - (void)testDataByDecodingBase64 {
47 | NSData *data = [@"44GC44GE44GG44GI44GK" dataUsingDecodingBase64];
48 | NSString *str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
49 | assertThat(str, equalTo(@"あいうえお"));
50 | }
51 |
52 | @end
53 |
--------------------------------------------------------------------------------
/OverlineTests/NSString/NSString+URLEncodeTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSString+URLEncodeTest.m
3 | // Copyright 2012 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSString+OVURLEncode.h"
13 |
14 | @interface NSString_URLEncodeTest : SenTestCase
15 | {
16 |
17 | }
18 | @end
19 |
20 | @implementation NSString_URLEncodeTest
21 |
22 | - (void)testURLEncode {
23 |
24 | // FIXME: OCHamcrest assertions bug ?
25 | // assertThat([@"http://example.com/?query=value&list[]=hoge&list[]=fuga#!hashあ" URLEncode], equalTo(@"http%3A%2F%2Fexample%2Ecom%2F%3Fquery%3Dvalue%26list%5B%5D%3Dhoge%26list%5B%5D%3Dfuga%23%21hash%E3%81%82"));
26 | STAssertEqualObjects([@"http://example.com/?query=value&list[]=hoge&list[]=fuga#!hashあ" URLEncode], @"http%3A%2F%2Fexample%2Ecom%2F%3Fquery%3Dvalue%26list%5B%5D%3Dhoge%26list%5B%5D%3Dfuga%23%21hash%E3%81%82", @"URIEncode");
27 | }
28 |
29 | - (void)testStringByEncodingURL {
30 |
31 | STAssertEqualObjects([@"http://example.com/?query=value&list[]=hoge&list[]=fuga#!hashあ" stringByEncodingURL], @"http%3A%2F%2Fexample%2Ecom%2F%3Fquery%3Dvalue%26list%5B%5D%3Dhoge%26list%5B%5D%3Dfuga%23%21hash%E3%81%82", @"URIEncode");
32 | }
33 |
34 | - (void)testURLDecode {
35 |
36 | assertThat([@"http%3a%2f%2fexample%2ecom%2f%3fquery%3dvalue%26list%5b%5d%3dhoge%26list%5b%5d%3dfuga%23%21hash%e3%81%82" URLDecode], equalTo(@"http://example.com/?query=value&list[]=hoge&list[]=fuga#!hashあ"));
37 | }
38 |
39 | - (void)testStringByDecodingURL {
40 |
41 | assertThat([@"http%3a%2f%2fexample%2ecom%2f%3fquery%3dvalue%26list%5b%5d%3dhoge%26list%5b%5d%3dfuga%23%21hash%e3%81%82" stringByDecodingURL], equalTo(@"http://example.com/?query=value&list[]=hoge&list[]=fuga#!hashあ"));
42 | }
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/Overline/Over/NSArray/NSArray+OVEnumeration.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/04.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSArray+OVEnumeration.h"
9 | #import "NSArray+OVSelector.h"
10 |
11 |
12 | @implementation NSArray (OVEnumeration)
13 |
14 | - (NSArray *)mappedArrayUsingBlock:(id (^)(id, NSUInteger))block {
15 | NSMutableArray *mappedArray = [NSMutableArray array];
16 | [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
17 | id o = block(obj, idx);
18 | if (o != nil) {
19 | [mappedArray addObject:o];
20 | }
21 | }];
22 | return mappedArray;
23 | }
24 |
25 | - (id)reducedObjectByBlock:(id (^)(id, id))block memo:(id)memo {
26 | __block id reducedObject = memo;
27 | [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
28 | reducedObject = block(reducedObject, obj);
29 | }];
30 | return reducedObject;
31 | }
32 |
33 | - (id)find:(BOOL (^)(id, NSUInteger))block {
34 | return [self objectUsingBlock:block];
35 | }
36 |
37 | - (id)objectUsingBlock:(BOOL (^)(id, NSUInteger))block {
38 | return [[self filteredArrayUsingBlock:block] firstObject];
39 | }
40 |
41 | - (NSArray *)filteredArrayUsingBlock:(BOOL (^)(id, NSUInteger))block opposite:(BOOL)opposite{
42 | NSMutableArray *filteredArray = [NSMutableArray array];
43 | [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
44 | BOOL r = block(obj, idx);
45 | if (r == !opposite) {
46 | [filteredArray addObject:obj];
47 | }
48 | }];
49 | return filteredArray;
50 | }
51 |
52 | - (NSArray *)filteredArrayUsingBlock:(BOOL (^)(id, NSUInteger))block {
53 | return [self filteredArrayUsingBlock:block opposite:NO];
54 | }
55 |
56 |
57 | - (NSArray *)rejectedArrayUsingBlock:(BOOL (^)(id, NSUInteger))block {
58 | return [self filteredArrayUsingBlock:block opposite:YES];
59 | }
60 |
61 | @end
--------------------------------------------------------------------------------
/Overline.xcworkspace/xcshareddata/Overline.xccheckout:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDESourceControlProjectFavoriteDictionaryKey
6 |
7 | IDESourceControlProjectIdentifier
8 | 4BCF3386-BA1D-4E2F-89BF-897CEF61E207
9 | IDESourceControlProjectName
10 | Overline
11 | IDESourceControlProjectOriginsDictionary
12 |
13 | 5ECA48E4-2F22-44C0-A3CA-0A331F9AA989
14 | ssh://github.com/Club15CC/SoundWandMIDI.git
15 | AA744DBC-9670-4ED1-BBB9-8C3E9F900040
16 | ssh://github.com/yaakaito/Overline.git
17 |
18 | IDESourceControlProjectPath
19 | Vendor/Overline/Overline.xcworkspace
20 | IDESourceControlProjectRelativeInstallPathDictionary
21 |
22 | 5ECA48E4-2F22-44C0-A3CA-0A331F9AA989
23 | ../../..
24 | AA744DBC-9670-4ED1-BBB9-8C3E9F900040
25 | ..
26 |
27 | IDESourceControlProjectURL
28 | ssh://github.com/yaakaito/Overline.git
29 | IDESourceControlProjectVersion
30 | 110
31 | IDESourceControlProjectWCCIdentifier
32 | 5ECA48E4-2F22-44C0-A3CA-0A331F9AA989
33 | IDESourceControlProjectWCConfigurations
34 |
35 |
36 | IDESourceControlRepositoryExtensionIdentifierKey
37 | public.vcs.git
38 | IDESourceControlWCCIdentifierKey
39 | AA744DBC-9670-4ED1-BBB9-8C3E9F900040
40 | IDESourceControlWCCName
41 | Overline
42 |
43 |
44 | IDESourceControlRepositoryExtensionIdentifierKey
45 | public.vcs.git
46 | IDESourceControlWCCIdentifierKey
47 | 5ECA48E4-2F22-44C0-A3CA-0A331F9AA989
48 | IDESourceControlWCCName
49 | SoundWand-Midi
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/OverlineTests/NSArray/NSArray+SubArrayTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSArray+SubArrayTest.m
3 | // Copyright 2013 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSArray+OVSubArray.h"
13 |
14 | @interface NSArray_SubArrayTest : SenTestCase
15 | {
16 |
17 | }
18 | @end
19 |
20 | @implementation NSArray_SubArrayTest
21 |
22 |
23 | - (void)testSubarrayFromIndex {
24 | NSArray *sub = [@[@1,@2,@3,@4,@5,@6] subarrayFromIndex:3];
25 | assertThat(sub, equalTo(@[@4,@5,@6]));
26 | }
27 |
28 | - (void)testSubarrayFromIndexLength {
29 | NSArray *sub = [@[@1,@2,@3,@4,@5,@6] subarrayFromIndex:3 length:2];
30 | assertThat(sub, equalTo(@[@4,@5]));
31 | }
32 |
33 | - (void)testSubarrayToIndex {
34 | NSArray *sub = [@[@1,@2,@3,@4,@5,@6] subarrayToIndex:3];
35 | assertThat(sub, equalTo(@[@1,@2,@3,@4]));
36 | }
37 |
38 | - (void)testUniqueObjects {
39 | NSArray *uniqueObjects = [@[@1, @2, @3, @1, @3, @4, @5] uniqueObjects];
40 | assertThat(uniqueObjects, equalTo(@[@1, @2, @3, @4, @5]));
41 | }
42 |
43 | - (void)testUniqueObjectsUsingEqualsBlock {
44 |
45 | NSArray *uniqueObjects = [@[@{
46 | @"name" : @"1",
47 | @"value" : @"aaa"
48 | }, @{
49 | @"name" : @"2",
50 | @"value" : @"bbb"
51 | }, @{
52 | @"name" : @"3",
53 | @"value" : @"aaa"
54 | }, @{
55 | @"name" : @"4",
56 | @"value" : @"ccc"
57 | }, @{
58 | @"name" : @"5",
59 | @"value" : @"ccc"
60 | }, @{
61 | @"name" : @"6",
62 | @"value" : @"ddd"
63 | }] uniqueObjectsUsingEqualsBlock:^BOOL(id left, id right) {
64 | return [[left objectForKey:@"value"] isEqual:[right objectForKey:@"value"]];
65 | }];
66 |
67 | assertThat(uniqueObjects, equalTo(@[@{
68 | @"name" : @"1",
69 | @"value" : @"aaa"
70 | }, @{
71 | @"name" : @"2",
72 | @"value" : @"bbb"
73 | }, @{
74 | @"name" : @"4",
75 | @"value" : @"ccc"
76 | } , @{
77 | @"name" : @"6",
78 | @"value" : @"ddd"
79 | }]));
80 | }
81 | @end
82 |
--------------------------------------------------------------------------------
/Overline/Over/NSDate/NSDate+OVComponents.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSDate+Components.h
3 | // Overline
4 | //
5 | // Created by Hari Karam Singh on 16/08/2013.
6 | // Copyright (c) 2013 yaakaito. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSDate (OVComponents)
12 |
13 | /////////////////////////////////////////////////////////////////////////
14 | #pragma mark - Class Methods
15 | /////////////////////////////////////////////////////////////////////////
16 |
17 | /** Weekday integer fur current day of the week. See -weekday */
18 | + (NSInteger)currentWeekday;
19 |
20 | /** Current hour based on the current calendar */
21 | + (NSInteger)currentHour;
22 |
23 | /** Current minute based on the current calendar */
24 | + (NSInteger)currentMinute;
25 |
26 | /** Current minute based on the current calendar */
27 | + (NSInteger)currentSecond;
28 |
29 | + (NSInteger)currentDay;
30 |
31 | + (NSInteger)currentMonth;
32 |
33 | + (NSInteger)currentYear;
34 |
35 | + (NSDateComponents *)commonDateComponentsForNow;
36 |
37 | + (NSDateComponents *)timeComponentsForNow;
38 |
39 | /////////////////////////////////////////////////////////////////////////
40 | #pragma mark - Instance Methods
41 | /////////////////////////////////////////////////////////////////////////
42 |
43 | /** Weekday integer 0-6 for M-S (for Gregorian, See NSDateComponents for more details) */
44 | - (NSInteger)weekday;
45 |
46 | /** Shortcut to get the date's hour in the current calendar */
47 | - (NSInteger)hour;
48 |
49 | /** Shortcut to get the date's minute in the current calendar */
50 | - (NSInteger)minute;
51 |
52 | /** Shortcut to get the date's second in the current calendar */
53 | - (NSInteger)second;
54 |
55 | /** Shortcut to get the date's day of the month in the current calendar */
56 | - (NSInteger)day;
57 |
58 | /** Shortcut to get the date's month in the current calendar */
59 | - (NSInteger)month;
60 |
61 | /** Shortcut to get the date's year in the current calendar */
62 | - (NSInteger)year;
63 |
64 | /** Returns date components for the calendar style date and time: year, month, day, hour, minute, second, weekday */
65 | - (NSDateComponents *)commonDateComponents;
66 |
67 | /** Returns an NSDateComponents with hour, minute, seconds */
68 | - (NSDateComponents *)timeComponents;
69 |
70 |
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/Overline/Over/NSLayoutConstraint/NSLayoutConstraint+OVConstructors.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSLayoutConstraint+OVConstructors.h
3 | // AC-Sabre
4 | //
5 | // Created by Hari Karam Singh on 05/06/2014.
6 | //
7 | //
8 |
9 | #import
10 |
11 | @interface NSLayoutConstraint (OVConstructors)
12 |
13 | /////////////////////////////////////////////////////////////////////////
14 | #pragma mark - Centering
15 | /////////////////////////////////////////////////////////////////////////
16 |
17 | /** A constraint for vertical center alignment of an item to it's superview */
18 | + (instancetype)constraintWithItemVerticallyCenteredInSuperview:(UIView *)aView;
19 |
20 | /** A constraint for horizontal center alignment of an item to it's superview */
21 | + (instancetype)constraintWithItemHorizontallyCenteredInSuperview:(UIView *)aView;
22 |
23 | /** Constraints for center alignment on both axes */
24 | + (NSArray *)constraintsWithItemCenteredInSuperview:(UIView *)aView;
25 |
26 |
27 | /////////////////////////////////////////////////////////////////////////
28 | #pragma mark - Alignment
29 | /////////////////////////////////////////////////////////////////////////
30 |
31 | /** Constraints array for equal alignment of a single attribute on multiple items (e.g. align vertical centers with NSLayoutAtributeCenterY) */
32 | + (NSArray *)constraintsForAligningAttribute:(NSLayoutAttribute)attribute ofItems:(NSArray *)items;
33 |
34 | /** Shorthand for a simple offset of two items wrt a single attribute. E.g. uilabel center vertically aligned to an image with an offset of 2 */
35 | + (instancetype)constraintWithAttribute:(NSLayoutAttribute)attribute ofItem:(id)item1 offsetBy:(CGFloat)offset toItem:(id)item2;
36 |
37 |
38 | /////////////////////////////////////////////////////////////////////////
39 | #pragma mark - Fixed Spacing
40 | /////////////////////////////////////////////////////////////////////////
41 |
42 | + (instancetype)constraintWithHorizontalSpacing:(CGFloat)spacing betweenItem:(id)item1 andItem:(id)item2;
43 |
44 | + (NSArray *)constraintsWithHorizontalSpacing:(CGFloat)spacing betweenItems:(NSArray *)items;
45 |
46 | + (instancetype)constraintWithVerticalSpacing:(CGFloat)spacing betweenItem:(id)item1 andItem:(id)item2;
47 |
48 | + (NSArray *)constraintsWithVerticalSpacing:(CGFloat)spacing betweenItems:(NSArray *)items;
49 |
50 |
51 |
52 |
53 |
54 | @end
55 |
--------------------------------------------------------------------------------
/Overline/Over/NSData/NSData+OVBase64Encode.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/01/05.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSData+OVBase64Encode.h"
9 | #import "OVBase64Encode.h"
10 |
11 | @implementation NSData (OVBase64Encode)
12 |
13 | - (NSString *)base64Encode {
14 | return [self stringUsingEncodingBase64];
15 | }
16 |
17 | - (NSString *)stringUsingEncodingBase64 {
18 | const unsigned char * objRawData = [self bytes];
19 | char * objPointer;
20 | char * strResult;
21 |
22 | // Get the Raw Data length and ensure we actually have data
23 | int intLength = [self length];
24 | if (intLength == 0) return nil;
25 |
26 | // Setup the String-based Result placeholder and pointer within that placeholder
27 | strResult = (char *)calloc((((intLength + 2) / 3) * 4) + 1, sizeof(char));
28 | objPointer = strResult;
29 |
30 | // Iterate through everything
31 | while (intLength > 2) { // keep going until we have less than 24 bits
32 | *objPointer++ = _base64EncodingTable[objRawData[0] >> 2];
33 | *objPointer++ = _base64EncodingTable[((objRawData[0] & 0x03) << 4) + (objRawData[1] >> 4)];
34 | *objPointer++ = _base64EncodingTable[((objRawData[1] & 0x0f) << 2) + (objRawData[2] >> 6)];
35 | *objPointer++ = _base64EncodingTable[objRawData[2] & 0x3f];
36 |
37 | // we just handled 3 octets (24 bits) of data
38 | objRawData += 3;
39 | intLength -= 3;
40 | }
41 |
42 | // now deal with the tail end of things
43 | if (intLength != 0) {
44 | *objPointer++ = _base64EncodingTable[objRawData[0] >> 2];
45 | if (intLength > 1) {
46 | *objPointer++ = _base64EncodingTable[((objRawData[0] & 0x03) << 4) + (objRawData[1] >> 4)];
47 | *objPointer++ = _base64EncodingTable[(objRawData[1] & 0x0f) << 2];
48 | *objPointer++ = '=';
49 | } else {
50 | *objPointer++ = _base64EncodingTable[(objRawData[0] & 0x03) << 4];
51 | *objPointer++ = '=';
52 | *objPointer++ = '=';
53 | }
54 | }
55 |
56 | // Terminate the string-based result
57 | *objPointer = '\0';
58 |
59 | // Create result NSString object
60 | NSString *base64String = [NSString stringWithCString:strResult encoding:NSASCIIStringEncoding];
61 |
62 | // Free memory
63 | free(strResult);
64 |
65 | return base64String;
66 | }
67 | @end
--------------------------------------------------------------------------------
/OverlineTests/NSNumber/NSNumber+EqualsTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSNumber+EqualsTest.m
3 | // Copyright 2012 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: kazuma.ukyo
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSNumber+OVEquals.h"
13 |
14 | @interface NSNumber_EqualsTest : SenTestCase
15 | {
16 |
17 | }
18 | @end
19 |
20 | @implementation NSNumber_EqualsTest
21 |
22 | - (void)testIsEqualToInt {
23 | assertThatBool([@2 isEqualToInt:2], equalToBool(YES));
24 | assertThatBool([@1 isEqualToInt:0], equalToBool(NO));
25 | }
26 |
27 | - (void)testIsEqualToInteger {
28 | assertThatBool([@2147483647 isEqualToInteger:(NSInteger)2147483647], equalToBool(YES));
29 | assertThatBool([@1 isEqualToInteger:0], equalToBool(NO));
30 | }
31 |
32 | - (void)testIsEqualToUnsignedInt {
33 | assertThatBool([@2 isEqualToUnsignedInt:2], equalToBool(YES));
34 | assertThatBool([@1 isEqualToUnsignedInt:0], equalToBool(NO));
35 | }
36 |
37 | - (void)testIsEqualToUnsignedInteger {
38 | assertThatBool([@4294967295 isEqualToUnsignedInteger:(NSUInteger)4294967295], equalToBool(YES));
39 | assertThatBool([@1 isEqualToUnsignedInteger:0], equalToBool(NO));
40 | }
41 |
42 | - (void)testIsEqualToLong {
43 | assertThatBool([@2147483647 isEqualToLong:(long)2147483647], equalToBool(YES));
44 | assertThatBool([@1 isEqualToLong:0], equalToBool(NO));
45 | }
46 |
47 | - (void)testIsEqualToLongLong {
48 | assertThatBool([@9223372036854775807 isEqualToLongLong:(long long)9223372036854775807], equalToBool(YES));
49 | assertThatBool([@1 isEqualToLongLong:0], equalToBool(NO));
50 | }
51 |
52 | - (void)testIsEqualToUnsignedLong {
53 | assertThatBool([@4294967295 isEqualToUnsignedLong:(unsigned long)4294967295], equalToBool(YES));
54 | assertThatBool([@1 isEqualToUnsignedLong:0], equalToBool(NO));
55 | }
56 |
57 | - (void)testIsEqualToUnsignedLongLong {
58 | assertThatBool([@18446744073709551615 isEqualToUnsignedLongLong:(unsigned long long)18446744073709551615], equalToBool(YES));
59 | assertThatBool([@1 isEqualToUnsignedLongLong:0], equalToBool(NO));
60 | }
61 |
62 | - (void)testIsEqualToDouble {
63 | assertThatBool([@0.5 isEqualToDouble:0.5], equalToBool(YES));
64 | assertThatBool([@0.1 isEqualToDouble:0], equalToBool(NO));
65 | }
66 |
67 | - (void)testIsEqualToFloat {
68 | assertThatBool([@0.5 isEqualToFloat:0.5], equalToBool(YES));
69 | assertThatBool([@0.1 isEqualToFloat:0], equalToBool(NO));
70 | }
71 |
72 |
73 | @end
74 |
--------------------------------------------------------------------------------
/Overline/Over/NSURL/NSURL+OVDirectories.m:
--------------------------------------------------------------------------------
1 |
2 | #import "NSURL+OVDirectories.h"
3 |
4 | @implementation NSURL (OVDirectories)
5 |
6 | + (NSURL *)URLForDirectory:(NSSearchPathDirectory)directoryConstant domainMask:(NSSearchPathDomainMask)domainMask
7 | {
8 | NSFileManager* sharedFM = [NSFileManager defaultManager];
9 | NSArray* possibleURLs = [sharedFM URLsForDirectory:directoryConstant
10 | inDomains:domainMask];
11 | NSURL* url = nil;
12 |
13 | if ([possibleURLs count] >= 1) {
14 | // Use the first directory (if multiple are returned)
15 | url = [possibleURLs objectAtIndex:0];
16 | }
17 |
18 | return url;
19 | }
20 |
21 | //---------------------------------------------------------------------
22 |
23 | + (NSURL *)URLForApplicationSupportDataDirectory
24 | {
25 | NSURL *appSupportDir = [self URLForDirectory:NSApplicationSupportDirectory domainMask:NSUserDomainMask];
26 |
27 | // If a valid app support directory exists, add the
28 | // app's bundle ID to it to specify the final directory.
29 | if (appSupportDir) {
30 | NSString* appBundleID = [[NSBundle mainBundle] bundleIdentifier];
31 | return [appSupportDir URLByAppendingPathComponent:appBundleID];
32 | } else
33 | return nil;
34 | }
35 |
36 | //---------------------------------------------------------------------
37 |
38 | + (NSURL *)URLForApplicationSupportWithAppendedPath:(NSString *)pathToAppend
39 | {
40 | return [[self URLForApplicationSupportDataDirectory] URLByAppendingPathComponent:pathToAppend];
41 | }
42 |
43 | //---------------------------------------------------------------------
44 |
45 | + (NSURL *)URLForUserDirectory
46 | {
47 | return [self URLForDirectory:NSUserDirectory domainMask:NSUserDomainMask];
48 | }
49 |
50 | //---------------------------------------------------------------------
51 |
52 | + (NSURL *)URLForUserDirectoryWithAppendedPath:(NSString *)pathToAppend
53 | {
54 | return [[self URLForUserDirectory] URLByAppendingPathComponent:pathToAppend];
55 |
56 | }
57 |
58 | //---------------------------------------------------------------------
59 |
60 | + (NSURL *)URLForDocumentDirectory
61 | {
62 | return [self URLForDirectory:NSDocumentDirectory domainMask:NSUserDomainMask];
63 | }
64 |
65 | //---------------------------------------------------------------------
66 |
67 | + (NSURL *)URLForDocumentDirectoryWithAppendedPath:(NSString *)pathToAppend
68 | {
69 | return [[self URLForDocumentDirectory] URLByAppendingPathComponent:pathToAppend];
70 | }
71 |
72 | @end
73 |
74 |
75 |
--------------------------------------------------------------------------------
/Overline/UIKit/UIView/UIView+OVPositioning.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+OVPositioning.h
3 | // Lab-VC-Transitions
4 | //
5 | // Created by Hari Karam Singh on 25/05/2014.
6 | // Copyright (c) 2014 Air Craft. All rights reserved.
7 |
8 | #import
9 |
10 | /** Shorthand and convenience methods for view positioning and size */
11 | @interface UIView (OVPositioning)
12 |
13 | /////////////////////////////////////////////////////////////////////////
14 | #pragma mark - Frame get/set shorthand
15 | /////////////////////////////////////////////////////////////////////////
16 |
17 | /** Frame origin/size */
18 | @property (nonatomic, assign) CGPoint origin;
19 | @property (nonatomic, assign) CGFloat x;
20 | @property (nonatomic, assign) CGFloat y;
21 |
22 | @property (nonatomic, assign) CGSize size;
23 | @property (nonatomic, assign) CGFloat width;
24 | @property (nonatomic, assign) CGFloat height;
25 |
26 | @property (nonatomic, assign) CGFloat centerX;
27 | @property (nonatomic, assign) CGFloat centerY;
28 |
29 |
30 | /////////////////////////////////////////////////////////////////////////
31 | #pragma mark - Bounds shorthand
32 | /////////////////////////////////////////////////////////////////////////
33 |
34 | @property (nonatomic, assign) CGSize boundsSize;
35 | @property (nonatomic, assign) CGFloat boundsWidth;
36 | @property (nonatomic, assign) CGFloat boundsHeight;
37 |
38 |
39 | /////////////////////////////////////////////////////////////////////////
40 | #pragma mark - Additional setters
41 | /////////////////////////////////////////////////////////////////////////
42 |
43 | /** Centers view in superview.
44 | @throws NSGenericException if superview = nil */
45 | - (void)alignCenterHorizontally;
46 |
47 | /** Centers view in superview.
48 | @throws NSGenericException if superview = nil */
49 | - (void)alignCenterVertically;
50 |
51 | /** Centers view in superview.
52 | @throws NSGenericException if superview = nil */
53 | - (void)alignCenter;
54 |
55 | /** Aligns right edge to that of the superview.
56 | @throws NSGenericException if superview = nil */
57 | - (void)alignRight;
58 |
59 | /** Aligns bottom edge to that of the superview.
60 | @throws NSGenericException if superview = nil */
61 | - (void)alignBottom;
62 |
63 | /** Layout with respect to the superview.
64 | @throws NSGenericException if superview = nil */
65 | - (void)setMargins:(UIEdgeInsets)margins;
66 |
67 | /** Positions the view a given distance from the bottom boundary of the superview changing the frame origin (as opposed to the size)
68 | @throws NSGenericException if superview = nil */
69 | - (void)setBottomMargin:(CGFloat)bottom;
70 |
71 | @end
72 |
--------------------------------------------------------------------------------
/Overline/UIKit/UIImage/UIImage+OVGradients.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+OVGradients.m
3 | // Lab-VC-Transitions
4 | //
5 | // Created by Hari Karam Singh on 23/05/2014.
6 | // Copyright (c) 2014 Air Craft. All rights reserved.
7 | //
8 |
9 | #import "UIImage+OVGradients.h"
10 |
11 | @implementation UIImage (OVGradients)
12 |
13 | + (UIImage *)gradientImageWithSize:(CGSize)size colors:(NSDictionary *)locationsColorsDict startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint
14 | {
15 | UIImage *resultImg;
16 | UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
17 | {
18 | CGContextRef ctx = UIGraphicsGetCurrentContext();
19 |
20 | // Convert dict to C arrays
21 | NSUInteger count = locationsColorsDict.count;
22 | CGFloat *locations = malloc(count * sizeof(CGFloat));
23 | CGFloat *components = malloc(count * sizeof(CGFloat) * 4); // assumes RGBA color space
24 | NSArray *locsArr = locationsColorsDict.allKeys;
25 | for (int i=0; i
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSNull+OVNatural.h"
13 | #import "NSObject+Equals.h"
14 |
15 | @interface NSObject_EqualsTest : SenTestCase
16 | {
17 |
18 | }
19 | @end
20 |
21 | @implementation NSObject_EqualsTest
22 |
23 | - (void)testIsNullObject
24 | {
25 | assertThatBool([[NSArray array] isNullObject], equalToBool(NO));
26 | assertThatBool([@1 isNullObject], equalToBool(NO));
27 | assertThatBool([@"string" isNullObject], equalToBool(NO));
28 | assertThatBool([[NSNull null] isNullObject], equalToBool(YES));
29 | }
30 |
31 | - (void)testIsArray {
32 | assertThatBool([[NSArray array] isArray], equalToBool(YES));
33 | assertThatBool([[NSDictionary dictionary] isArray], equalToBool(NO));
34 | assertThatBool([[NSSet set] isArray], equalToBool(NO));
35 | assertThatBool([[NSString string] isArray], equalToBool(NO));
36 | assertThatBool([[NSNumber numberWithBool:YES] isArray], equalToBool(NO));
37 | assertThatBool([[[NSObject alloc] init] isArray], equalToBool(NO));
38 | }
39 |
40 | - (void)testIsDictionary {
41 | assertThatBool([[NSDictionary dictionary] isDictionary], equalToBool(YES));
42 | assertThatBool([[NSArray array] isDictionary], equalToBool(NO));
43 | assertThatBool([[NSSet set] isDictionary], equalToBool(NO));
44 | assertThatBool([[NSString string] isDictionary], equalToBool(NO));
45 | assertThatBool([[NSNumber numberWithBool:YES] isDictionary], equalToBool(NO));
46 | assertThatBool([[[NSObject alloc] init] isDictionary], equalToBool(NO));
47 | }
48 |
49 | - (void)testIsSet {
50 | assertThatBool([[NSSet set] isSet], equalToBool(YES));
51 | assertThatBool([[NSDictionary dictionary] isSet], equalToBool(NO));
52 | assertThatBool([[NSArray array] isSet], equalToBool(NO));
53 | assertThatBool([[NSString string] isSet], equalToBool(NO));
54 | assertThatBool([[NSNumber numberWithBool:YES] isSet], equalToBool(NO));
55 | assertThatBool([[[NSObject alloc] init] isSet], equalToBool(NO));
56 | }
57 |
58 | - (void)testIsString {
59 | assertThatBool([[NSString string] isString], equalToBool(YES));
60 | assertThatBool([[NSDictionary dictionary] isString], equalToBool(NO));
61 | assertThatBool([[NSArray array] isString], equalToBool(NO));
62 | assertThatBool([[NSSet set] isString], equalToBool(NO));
63 | assertThatBool([[NSNumber numberWithBool:YES] isString], equalToBool(NO));
64 | assertThatBool([[[NSObject alloc] init] isString], equalToBool(NO));
65 | }
66 |
67 | - (void)testIsNumber {
68 | assertThatBool([[NSNumber numberWithBool:YES] isNumber], equalToBool(YES));
69 | assertThatBool([[NSDictionary dictionary] isNumber], equalToBool(NO));
70 | assertThatBool([[NSArray array] isNumber], equalToBool(NO));
71 | assertThatBool([[NSSet set] isNumber], equalToBool(NO));
72 | assertThatBool([[NSString string] isNumber], equalToBool(NO));
73 | assertThatBool([[[NSObject alloc] init] isNumber], equalToBool(NO));
74 | }
75 | @end
76 |
--------------------------------------------------------------------------------
/Overline/Over/NSDictionary/NSDictionary+OVSelector.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/03/22.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSDictionary+OVSelector.h"
9 |
10 |
11 | @implementation NSDictionary (OVSelector)
12 |
13 | - (id)objectForKey:(id)aKey transformBlock:(id (^)(id))block {
14 | return block([self objectForKey:aKey]);
15 | }
16 |
17 | - (NSNumber *)numberForKey:(id)aKey {
18 | return (NSNumber *)[self objectForKey:aKey];
19 | }
20 |
21 | - (NSString *)stringForKey:(id)aKey {
22 | return (NSString *)[self objectForKey:aKey];
23 | }
24 |
25 | - (NSArray *)arrayForKey:(id)aKey {
26 | return (NSArray *)[self objectForKey:aKey];
27 | }
28 |
29 | - (NSDictionary *)dictionaryForKey:(id)aKey {
30 | return (NSDictionary *)[self objectForKey:aKey];
31 | }
32 |
33 | - (NSDate *)dateForKey:(id)aKey {
34 | return [self dateForKey:aKey usingFormat:@"yyyy/MM/dd HH:mm:ss Z"];
35 | }
36 |
37 | - (NSDate *)dateForKey:(id)aKey usingFormat:(NSString *)formatString {
38 | return [self objectForKey:aKey transformBlock:^id(id obj) {
39 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
40 | [formatter setDateFormat:formatString];
41 | return [formatter dateFromString:obj];
42 | }];
43 | }
44 |
45 | - (NSDate *)since1970DateForKey:(NSString *)aKey {
46 | return [NSDate dateWithTimeIntervalSince1970:[self doubleForKey:aKey]];
47 | }
48 |
49 | - (NSDate *)timestampForKey:(NSString *)aKey {
50 | return [self since1970DateForKey:aKey];
51 | }
52 |
53 | - (NSNumber *)boolObjectForKey:(NSString *)aKey withTrueValue:(id)value {
54 | return [self objectForKey:aKey transformBlock:^id(id obj) {
55 | if ([value isEqual:obj]) {
56 | return [NSNumber numberWithBool:YES];
57 | }
58 | return [NSNumber numberWithBool:NO];
59 | }];
60 | }
61 |
62 | - (BOOL)boolForKey:(id)aKey withTureValue:(id)value {
63 | return [[self boolObjectForKey:aKey withTrueValue:value] boolValue];
64 | }
65 |
66 | - (BOOL)boolForKey:(id)aKey {
67 | return [[self objectForKey:aKey] boolValue];
68 | }
69 |
70 | - (int)intForKey:(id)aKey {
71 | return [[self objectForKey:aKey] intValue];
72 | }
73 |
74 | - (NSInteger)integerForKey:(id)aKey {
75 | return [[self objectForKey:aKey] integerValue];
76 | }
77 |
78 | - (unsigned int)unsignedIntForKey:(id)aKey {
79 | return [[self objectForKey:aKey] unsignedIntValue];
80 | }
81 |
82 | - (NSUInteger)unsignedIntegerForKey:(id)aKey {
83 | return [[self objectForKey:aKey] unsignedIntegerValue];
84 | }
85 |
86 | - (long)longForKey:(id)aKey {
87 | return [[self objectForKey:aKey] longValue];
88 | }
89 |
90 | - (unsigned long)unsignedLongForKey:(id)aKey {
91 | return [[self objectForKey:aKey] unsignedLongValue];
92 | }
93 |
94 | - (long long)longLongForKey:(id)aKey {
95 | return [[self objectForKey:aKey] longLongValue];
96 | }
97 |
98 | - (unsigned long long int)unsignedLongLongForKey:(id)aKey {
99 | return [[self objectForKey:aKey] unsignedLongLongValue];
100 | }
101 |
102 | - (double)doubleForKey:(id)aKey {
103 | return [[self objectForKey:aKey] doubleValue];
104 | }
105 |
106 | - (float)floatForKey:(id)aKey {
107 | return [[self objectForKey:aKey] floatValue];
108 | }
109 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSString/NSString+OVBase64Encode.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2013/01/05.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSString+OVBase64Encode.h"
9 | #import "OVBase64Encode.h"
10 | #import "NSData+OVBase64Encode.h"
11 |
12 | @implementation NSString (OVBase64Encode)
13 |
14 | - (NSString *)encodeBase64 {
15 | return [self stringByEncodingBase64];
16 | }
17 |
18 | - (NSString *)stringByEncodingBase64 {
19 | NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding];
20 | return [data stringUsingEncodingBase64];
21 | }
22 |
23 | - (NSString *)decodeBase64 {
24 | return [self stringByDecodingBase64];
25 | }
26 |
27 | - (NSString *)stringByDecodingBase64 {
28 | NSData *data = [self dataUsingDecodingBase64];
29 | return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
30 | }
31 |
32 | - (NSData *)dataUsingDecodingBase64 {
33 |
34 | const char *objPointer = [self cStringUsingEncoding:NSASCIIStringEncoding];
35 | size_t intLength = strlen(objPointer);
36 | int intCurrent;
37 | int i = 0, j = 0, k;
38 |
39 | unsigned char *objResult = calloc(intLength, sizeof(unsigned char));
40 |
41 | // Run through the whole string, converting as we go
42 | while ( ((intCurrent = *objPointer++) != '\0') && (intLength-- > 0) ) {
43 | if (intCurrent == '=') {
44 | if (*objPointer != '=' && ((i % 4) == 1)) {// || (intLength > 0)) {
45 | // the padding character is invalid at this point -- so this entire string is invalid
46 | free(objResult);
47 | return nil;
48 | }
49 | continue;
50 | }
51 |
52 | intCurrent = _base64DecodingTable[intCurrent];
53 | if (intCurrent == -1) {
54 | // we're at a whitespace -- simply skip over
55 | continue;
56 | } else if (intCurrent == -2) {
57 | // we're at an invalid character
58 | free(objResult);
59 | return nil;
60 | }
61 |
62 | switch (i % 4) {
63 | case 0:
64 | objResult[j] = intCurrent << 2;
65 | break;
66 |
67 | case 1:
68 | objResult[j++] |= intCurrent >> 4;
69 | objResult[j] = (intCurrent & 0x0f) << 4;
70 | break;
71 |
72 | case 2:
73 | objResult[j++] |= intCurrent >>2;
74 | objResult[j] = (intCurrent & 0x03) << 6;
75 | break;
76 |
77 | case 3:
78 | objResult[j++] |= intCurrent;
79 | break;
80 | }
81 | i++;
82 | }
83 |
84 | // mop things up if we ended on a boundary
85 | k = j;
86 | if (intCurrent == '=') {
87 | switch (i % 4) {
88 | case 1:
89 | // Invalid state
90 | free(objResult);
91 | return nil;
92 |
93 | case 2:
94 | k++;
95 | // flow through
96 | case 3:
97 | objResult[k] = 0;
98 | }
99 | }
100 |
101 | // Cleanup and setup the return NSData
102 | NSData * objData = [[NSData alloc] initWithBytes:objResult length:j];
103 | free(objResult);
104 | return objData;
105 | }
106 | @end
--------------------------------------------------------------------------------
/OverlineTests/NSArray/NSArray+EnumerationTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSArray+Enumeration.m
3 | // Copyright 2012 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSArray+OVEnumeration.h"
13 | #import "NSArray+OVCore.h"
14 |
15 | @interface NSArray_Enumeration : SenTestCase
16 | {
17 |
18 | }
19 | @end
20 |
21 | @implementation NSArray_Enumeration
22 |
23 | - (void)testEach
24 | {
25 | __block NSUInteger lastIdx;
26 | [@[@1, @2, @3] each:^(id obj, NSUInteger idx) {
27 | assertThat(obj, equalTo([@[@1, @2, @3] objectAtIndex:idx]));
28 | lastIdx = idx;
29 | }];
30 | assertThat(@(lastIdx), equalTo(@2));
31 | }
32 |
33 | - (void)testMap
34 | {
35 | NSArray *mapped = [@[@1,@2,@3,@4,@5,@6] map:^id(id obj, NSUInteger idx) {
36 | if ([obj integerValue] % 2 == 0) {
37 | return obj;
38 | }
39 | return nil;
40 | }];
41 | assertThat(mapped, equalTo(@[@2,@4,@6]));
42 | }
43 |
44 | - (void)testMappedArrayUsingBlock
45 | {
46 | NSArray *mapped = [@[@1,@2,@3,@4,@5,@6] mappedArrayUsingBlock:^id(id obj, NSUInteger idx) {
47 | if ([obj integerValue] % 2 == 0) {
48 | return obj;
49 | }
50 | return nil;
51 | }];
52 | assertThat(mapped, equalTo(@[@2,@4,@6]));
53 | }
54 |
55 | - (void)testReduce
56 | {
57 | id obj = [@[@1,@2,@3] reduce:^id(id memo, id obj) {
58 | return @([memo integerValue] + [obj integerValue]);
59 | } memo:@0];
60 | assertThat(obj, equalTo(@6));
61 | }
62 |
63 | - (void)reducedObjectByBlock
64 | {
65 | id obj = [@[@1,@2,@3] reducedObjectByBlock:^id(id memo, id obj) {
66 | return @([memo integerValue] + [obj integerValue]);
67 | } memo:@0];
68 | assertThat(obj, equalTo(@6));
69 | }
70 |
71 | - (void)testFind
72 | {
73 | id obj = [@[@1,@2,@3,@4,@5,@6] find:^BOOL(id obj, NSUInteger idx) {
74 | return [obj integerValue] % 2 == 0;
75 | }];
76 | assertThat(obj, equalTo(@2));
77 | }
78 |
79 | - (void)testObjectUsingBlock
80 | {
81 | id obj = [@[@1,@2,@3,@4,@5,@6] objectUsingBlock:^BOOL(id obj, NSUInteger idx) {
82 | return [obj integerValue] % 2 == 0;
83 | }];
84 | assertThat(obj, equalTo(@2));
85 | }
86 |
87 | - (void)testFilter {
88 |
89 | id obj = [@[@1,@2,@3,@4,@5,@6] filter:^BOOL(id obj, NSUInteger idx) {
90 | return [obj integerValue] % 2 == 0;
91 | }];
92 | assertThat(obj, equalTo(@[@2,@4,@6]));
93 | }
94 |
95 | - (void)testFilteredArrayUsingBlock {
96 |
97 | id obj = [@[@1,@2,@3,@4,@5,@6] filteredArrayUsingBlock:^BOOL(id obj, NSUInteger idx) {
98 | return [obj integerValue] % 2 == 0;
99 | }];
100 | assertThat(obj, equalTo(@[@2,@4,@6]));
101 | }
102 |
103 | - (void)testReject {
104 | NSArray *rejected = [@[@1,@2,@3,@4,@5,@6] reject:^BOOL(id obj, NSUInteger idx) {
105 | return [obj integerValue] % 2 == 0;
106 | }];
107 | assertThat(rejected, equalTo(@[@1,@3,@5]));
108 | }
109 |
110 | - (void)testRejectedArrayUsingBlock {
111 | NSArray *rejected = [@[@1,@2,@3,@4,@5,@6] rejectedArrayUsingBlock:^BOOL(id obj, NSUInteger idx) {
112 | return [obj integerValue] % 2 == 0;
113 | }];
114 | assertThat(rejected, equalTo(@[@1,@3,@5]));
115 | }
116 |
117 |
118 | @end
119 |
--------------------------------------------------------------------------------
/Overline/Over/NSDictionary/NSDictionary+OVEnumeration.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/24.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSDictionary+OVEnumeration.h"
9 |
10 | @implementation NSDictionary (OVEnumeration)
11 |
12 | - (NSDictionary *)mappedDictionaryUsingBlock:(id (^)(id, NSString *))block {
13 | NSMutableDictionary *result = [NSMutableDictionary dictionary];
14 | [self enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
15 | id o = block(obj, key);
16 | if (o) {
17 | [result setValue:o forKey:key];
18 | }
19 | }];
20 | return result;
21 | }
22 |
23 | - (NSArray *)arrayMap:(id (^)(id, NSString *))block {
24 | return [self mappedArrayUsingBlock:block];
25 | }
26 |
27 | - (NSArray *)mappedArrayUsingBlock:(id (^)(id, NSString *))block {
28 | NSMutableArray *result = [NSMutableArray array];
29 | [self enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
30 | id o = block(obj, key);
31 | if (o) {
32 | [result addObject:o];
33 | }
34 | }];
35 | return result;
36 | }
37 |
38 | - (NSDictionary *)filteredDictionaryUsingBlock:(BOOL (^)(id key, id obj))block opposite:(BOOL)opposite {
39 | NSMutableDictionary *result = [NSMutableDictionary dictionary];
40 | [self enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
41 | BOOL r = block(key, obj);
42 | if (r == !opposite) {
43 | [result setObject:obj forKey:key];
44 | }
45 | }];
46 | return result;
47 | }
48 |
49 | - (NSDictionary *)filterKey:(BOOL (^)(NSString *))block {
50 | return [self dictionaryFilteredByKeyUsingBlock:block];
51 | }
52 |
53 | - (NSDictionary *)dictionaryFilteredByKeyUsingBlock:(BOOL (^)(NSString *))block {
54 | return [self filteredDictionaryUsingBlock:^BOOL(id key, id obj) {
55 | return block(key);
56 | } opposite:NO];
57 | }
58 |
59 | - (NSDictionary *)rejectKey:(BOOL (^)(NSString *))block {
60 | return [self dictionaryRejectedByKeyUsingBlock:block];
61 | }
62 |
63 | - (NSDictionary *)dictionaryRejectedByKeyUsingBlock:(BOOL (^)(NSString *))block {
64 | return [self filteredDictionaryUsingBlock:^BOOL(id key, id obj) {
65 | return block(key);
66 | } opposite:YES];
67 | }
68 |
69 | - (NSDictionary *)filterObject:(BOOL (^)(id))block {
70 | return [self dictionaryFilteredByObjectUsingBlock:block];
71 | }
72 |
73 | - (NSDictionary *)dictionaryFilteredByObjectUsingBlock:(BOOL (^)(id))block {
74 | return [self filteredDictionaryUsingBlock:^BOOL(id key, id obj) {
75 | return block(obj);
76 | } opposite:NO];
77 | }
78 |
79 | - (NSDictionary *)rejectObject:(BOOL (^)(id))block {
80 | return [self dictionaryRejectedByObjectUsingBlock:block];
81 | }
82 |
83 | - (NSDictionary *)dictionaryRejectedByObjectUsingBlock:(BOOL (^)(id))block {
84 | return [self filteredDictionaryUsingBlock:^BOOL(id key, id obj) {
85 | return block(obj);
86 | } opposite:YES];
87 | }
88 |
89 | - (NSDictionary *)merge:(NSDictionary *)dictionary {
90 | return [self dictionaryByMergingDictionary:dictionary];
91 | }
92 |
93 | - (NSDictionary *)dictionaryByMergingDictionary:(NSDictionary *)dictionary {
94 | NSMutableDictionary *that = [self mutableCopy];
95 | [dictionary enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
96 | [that setValue:obj forKey:key];
97 | }];
98 | return that;
99 | }
100 |
101 | - (id)reducedObjectUsingBlock:(id (^)(id, id, NSString *))block memo:(id)memo {
102 | __block id reduceObject = memo;
103 | [self enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
104 | reduceObject = block(reduceObject, obj, key);
105 | }];
106 | return reduceObject;
107 | }
108 |
109 | - (NSString *)queryString {
110 | return [self stringByFormattingQuery];
111 | }
112 |
113 | - (NSString *)stringByFormattingQuery {
114 | return [self reducedObjectUsingBlock:^id(id memo, id obj, NSString *key) {
115 | if ([memo length] > 0) {
116 | return [memo stringByAppendingString:[NSString stringWithFormat:@"&%@=%@", key, obj]];
117 | }
118 | return [memo stringByAppendingString:[NSString stringWithFormat:@"%@=%@", key, obj]];
119 | } memo:@""];
120 | }
121 | @end
--------------------------------------------------------------------------------
/Overline/Over/NSString/NSString+OVRegularExpression.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by yaakaito on 2012/12/16.
3 | //
4 | // To change the template use AppCode | Preferences | File Templates.
5 | //
6 |
7 |
8 | #import "NSString+OVRegularExpression.h"
9 | #import "NSArray+OVEnumeration.h"
10 |
11 | @implementation NSString (OVRegularExpression)
12 | - (NSRange)rangeOfFirstMatchInString:(NSString *)string {
13 | return [self rangeOfFirstMatchInString:string options:NSRegularExpressionSearch];
14 | }
15 |
16 | - (NSRange)rangeOfFirstMatchInString:(NSString *)string options:(NSRegularExpressionOptions)options {
17 | return [string rangeOfString:self options:options];
18 | }
19 |
20 | - (NSArray *)matchesInString:(NSString *)string {
21 | return [self matchesInString:string options:NSRegularExpressionSearch];
22 | }
23 |
24 | - (NSArray *)matchesInString:(NSString *)string options:(NSRegularExpressionOptions)options {
25 | NSError *error = nil;
26 | NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:self
27 | options:options
28 | error:&error];
29 | NSArray *maches = [regex matchesInString:string
30 | options:0 range:NSMakeRange(0, [string length])];
31 |
32 | return [maches mappedArrayUsingBlock:^id(id obj, NSUInteger idx) {
33 | NSTextCheckingResult *res = obj;
34 | return [string substringWithRange:[res range]];
35 | }];
36 | }
37 |
38 | - (BOOL)testInString:(NSString *)string {
39 | return [self testInString:string options:NSRegularExpressionSearch];
40 | }
41 |
42 | - (BOOL)testInString:(NSString *)string options:(NSRegularExpressionOptions)options {
43 | return [self rangeOfFirstMatchInString:string options:options].location != NSNotFound;
44 | }
45 |
46 | - (NSString *)replace:(NSString *)regexpPattern newString:(NSString *)string {
47 | return [self stringByReplacingOccurrencesOfRegExpPattern:regexpPattern withString:string];
48 | }
49 |
50 | - (NSString *)stringByReplacingOccurrencesOfRegExpPattern:(NSString *)regexpPattern withString:(NSString *)string {
51 | return [self stringByReplacingOccurrencesOfRegExpPattern:regexpPattern withString:string options:NSRegularExpressionSearch];
52 | }
53 |
54 | - (NSString *)replace:(NSString *)regexpPattern newString:(NSString *)string options:(NSRegularExpressionOptions)options {
55 | return [self stringByReplacingOccurrencesOfRegExpPattern:regexpPattern withString:string options:options];
56 | }
57 |
58 | - (NSString *)stringByReplacingOccurrencesOfRegExpPattern:(NSString *)regexpPattern withString:(NSString *)string options:(NSRegularExpressionOptions)options {
59 | NSError *error = nil;
60 | NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:regexpPattern
61 | options:options
62 | error:&error];
63 | NSString *replaced = [regexp stringByReplacingMatchesInString:self
64 | options:NSMatchingReportProgress
65 | range:NSMakeRange(0, self.length)
66 | withTemplate:string];
67 | return replaced;
68 | }
69 |
70 | - (NSString *)replace:(NSString *)regexpPattern withTemplate:(NSString *)aTemplate {
71 | return [self stringByReplacingOccurrencesOfRegExpPattern:regexpPattern withTemplate:aTemplate];
72 | }
73 |
74 | - (NSString *)stringByReplacingOccurrencesOfRegExpPattern:(NSString *)regexpPattern withTemplate:(NSString *)aTemplate {
75 | return [self stringByReplacingOccurrencesOfRegExpPattern:regexpPattern withTemplate:aTemplate options:NSRegularExpressionSearch];
76 | }
77 |
78 | - (NSString *)replace:(NSString *)regexpPattern withTemplate:(NSString *)aTemplate options:(NSRegularExpressionOptions)options {
79 | return [self stringByReplacingOccurrencesOfRegExpPattern:regexpPattern withTemplate:aTemplate options:options];
80 | }
81 |
82 | - (NSString *)stringByReplacingOccurrencesOfRegExpPattern:(NSString *)regexpPattern withTemplate:(NSString *)aTemplate options:(NSRegularExpressionOptions)options {
83 | return [self stringByReplacingOccurrencesOfRegExpPattern:regexpPattern withString:aTemplate options:options];
84 | }
85 | @end
--------------------------------------------------------------------------------
/OverlineTests/NSSet/NSSet+EnumerationTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSSet+EnumerationTest.m
3 | // Copyright 2013 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSSet+OVEnumeration.h"
13 | #import "NSString+OVRegularExpression.h"
14 | #import "NSSet+OVCore.h"
15 |
16 | @interface NSSet_EnumerationTest : SenTestCase
17 | {
18 |
19 | }
20 | @end
21 |
22 | @implementation NSSet_EnumerationTest
23 |
24 | - (void)testEach {
25 | __block NSUInteger count = 0;
26 | NSSet *set = [NSSet setWithArray:@[@"A", @"B", @"C"]];
27 | [set each:^(id obj) {
28 | assertThatBool([@"^[ABC]$" testInString:obj], equalToBool(YES));
29 | count++;
30 | }];
31 | }
32 |
33 | - (void)testMap {
34 | NSSet *set = [NSSet setWithArray:@[@1, @2, @3, @4, @5, @6]];
35 | NSSet *mapped = [set map:^id(id obj) {
36 | if ([obj integerValue] % 2 == 0){
37 | return obj;
38 | }
39 | return nil;
40 | }];
41 |
42 | NSArray *ary = [[mapped allObjects] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
43 | return (NSComparisonResult)([obj1 integerValue] - [obj2 integerValue]);
44 | }];
45 |
46 | assertThat(ary, equalTo(@[@2,@4,@6]));
47 | }
48 |
49 |
50 |
51 | - (void)testMappedSetUsingBlock {
52 | NSSet *set = [NSSet setWithArray:@[@1, @2, @3, @4, @5, @6]];
53 | NSSet *mapped = [set mappedSetUsingBlock:^id(id obj) {
54 | if ([obj integerValue] % 2 == 0){
55 | return obj;
56 | }
57 | return nil;
58 | }];
59 |
60 | NSArray *ary = [[mapped allObjects] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
61 | return (NSComparisonResult)([obj1 integerValue] - [obj2 integerValue]);
62 | }];
63 |
64 | assertThat(ary, equalTo(@[@2,@4,@6]));
65 | }
66 |
67 | - (void)testReduce {
68 | NSSet *set = [NSSet setWithArray:@[@1,@2,@3]];
69 | id obj = [set reduce:^id(id memo, id obj) {
70 | return @([memo integerValue] + [obj integerValue]);
71 | } memo:@0];
72 | assertThat(obj, equalTo(@6));
73 | }
74 |
75 | - (void)testReducedObjectByBlock {
76 | NSSet *set = [NSSet setWithArray:@[@1,@2,@3]];
77 | id obj = [set reducedObjectByBlock:^id(id memo, id obj) {
78 | return @([memo integerValue] + [obj integerValue]);
79 | } memo:@0];
80 | assertThat(obj, equalTo(@6));
81 | }
82 |
83 | - (void)testFilter {
84 | NSSet *set = [NSSet setWithArray:@[@1, @2, @3, @4, @5, @6]];
85 | NSSet *filtered = [set filter:^BOOL(id obj) {
86 | return [obj integerValue] % 2 == 0;
87 | }];
88 | NSArray *ary = [[filtered allObjects] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
89 | return (NSComparisonResult)([obj1 integerValue] - [obj2 integerValue]);
90 | }];
91 |
92 | assertThat(ary, equalTo(@[@2,@4,@6]));
93 | }
94 |
95 | - (void)testFilteredSetUsingBlock {
96 | NSSet *set = [NSSet setWithArray:@[@1, @2, @3, @4, @5, @6]];
97 | NSSet *filtered = [set filteredSetUsingBlock:^BOOL(id obj) {
98 | return [obj integerValue] % 2 == 0;
99 | }];
100 | NSArray *ary = [[filtered allObjects] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
101 | return (NSComparisonResult)([obj1 integerValue] - [obj2 integerValue]);
102 | }];
103 |
104 | assertThat(ary, equalTo(@[@2,@4,@6]));
105 |
106 | }
107 |
108 | - (void)testReject {
109 | NSSet *set = [NSSet setWithArray:@[@1, @2, @3, @4, @5, @6]];
110 | NSSet *rejected = [set reject:^BOOL(id obj) {
111 | return [obj integerValue] % 2 == 0;
112 | }];
113 | NSArray *ary = [[rejected allObjects] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
114 | return (NSComparisonResult)([obj1 integerValue] - [obj2 integerValue]);
115 | }];
116 |
117 | assertThat(ary, equalTo(@[@1,@3,@5]));
118 | }
119 |
120 | - (void)testRejectedSetUsingBlock {
121 | NSSet *set = [NSSet setWithArray:@[@1, @2, @3, @4, @5, @6]];
122 | NSSet *rejected = [set rejectedSetUsingBlock:^BOOL(id obj) {
123 | return [obj integerValue] % 2 == 0;
124 | }];
125 | NSArray *ary = [[rejected allObjects] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
126 | return (NSComparisonResult)([obj1 integerValue] - [obj2 integerValue]);
127 | }];
128 |
129 | assertThat(ary, equalTo(@[@1,@3,@5]));
130 | }
131 | @end
132 |
--------------------------------------------------------------------------------
/Overline/Over/NSDate/NSDate+OVComponents.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSDate+Components.m
3 | // Overline
4 | //
5 | // Created by Hari Karam Singh on 16/08/2013.
6 | // Copyright (c) 2013 yaakaito. All rights reserved.
7 | //
8 |
9 | #import "NSDate+OVComponents.h"
10 |
11 | @implementation NSDate (OVComponents)
12 |
13 |
14 | /////////////////////////////////////////////////////////////////////////
15 | #pragma mark - Class Methods
16 | /////////////////////////////////////////////////////////////////////////
17 |
18 | + (NSInteger)currentWeekday
19 | {
20 | return [NSDate.date weekday];
21 | }
22 |
23 | //---------------------------------------------------------------------
24 |
25 | + (NSInteger)currentHour
26 | {
27 | return [NSDate.date hour];
28 | }
29 |
30 | //---------------------------------------------------------------------
31 |
32 | + (NSInteger)currentMinute
33 | {
34 | return [NSDate.date minute];
35 | }
36 |
37 | //---------------------------------------------------------------------
38 |
39 | + (NSInteger)currentSecond
40 | {
41 | return [NSDate.date second];
42 | }
43 |
44 | //---------------------------------------------------------------------
45 |
46 | + (NSInteger)currentYear
47 | {
48 | return [NSDate.date year];
49 | }
50 |
51 | //---------------------------------------------------------------------
52 |
53 | + (NSInteger)currentMonth
54 | {
55 | return [NSDate.date month];
56 | }
57 |
58 | //---------------------------------------------------------------------
59 |
60 | + (NSInteger)currentDay
61 | {
62 | return [NSDate.date day];
63 | }
64 |
65 | //---------------------------------------------------------------------
66 |
67 | + (NSDateComponents *)commonDateComponentsForNow
68 | {
69 | return [NSDate.date commonDateComponents];
70 | }
71 |
72 | //---------------------------------------------------------------------
73 |
74 | + (NSDateComponents *)timeComponentsForNow
75 | {
76 | return [NSDate.date timeComponents];
77 | }
78 |
79 | /////////////////////////////////////////////////////////////////////////
80 | #pragma mark - Instance Methods
81 | /////////////////////////////////////////////////////////////////////////
82 |
83 |
84 |
85 | - (NSInteger)weekday
86 | {
87 | return [[NSCalendar currentCalendar] components:NSWeekCalendarUnit fromDate:self].weekday;
88 | }
89 |
90 | //---------------------------------------------------------------------
91 |
92 | - (NSInteger)hour
93 | {
94 | return [[NSCalendar currentCalendar] components:NSHourCalendarUnit fromDate:self].hour;
95 | }
96 |
97 | //---------------------------------------------------------------------
98 |
99 | - (NSInteger)minute
100 | {
101 | return [[NSCalendar currentCalendar] components:NSMinuteCalendarUnit fromDate:self].minute;
102 | }
103 |
104 | //---------------------------------------------------------------------
105 |
106 | - (NSInteger)second
107 | {
108 | return [[NSCalendar currentCalendar] components:NSSecondCalendarUnit fromDate:self].second;
109 | }
110 |
111 | //---------------------------------------------------------------------
112 |
113 | - (NSInteger)day
114 | {
115 | return [[NSCalendar currentCalendar] components:NSDayCalendarUnit fromDate:self].day;
116 | }
117 |
118 | //---------------------------------------------------------------------
119 |
120 | - (NSInteger)month
121 | {
122 | return [[NSCalendar currentCalendar] components:NSMonthCalendarUnit fromDate:self].month;
123 | }
124 |
125 | //---------------------------------------------------------------------
126 |
127 | - (NSInteger)year
128 | {
129 | return [[NSCalendar currentCalendar] components:NSYearCalendarUnit fromDate:self].year;
130 | }
131 |
132 | //---------------------------------------------------------------------
133 |
134 | - (NSDateComponents *)commonDateComponents
135 | {
136 | return [[NSCalendar currentCalendar] components:NSYearCalendarUnit |
137 | NSMonthCalendarUnit |
138 | NSDayCalendarUnit |
139 | NSWeekdayCalendarUnit |
140 | NSHourCalendarUnit |
141 | NSMinuteCalendarUnit |
142 | NSSecondCalendarUnit
143 | fromDate:self];
144 | }
145 |
146 | //---------------------------------------------------------------------
147 |
148 | - (NSDateComponents *)timeComponents
149 | {
150 | return [[NSCalendar currentCalendar] components:NSHourCalendarUnit |
151 | NSMinuteCalendarUnit |
152 | NSSecondCalendarUnit
153 | fromDate:self];
154 | }
155 |
156 |
157 |
158 |
159 | @end
160 |
--------------------------------------------------------------------------------
/Overline/Over/NSLayoutConstraint/NSLayoutConstraint+OVConstructors.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSLayoutConstraint+OVConstructors.m
3 | // AC-Sabre
4 | //
5 | // Created by Hari Karam Singh on 05/06/2014.
6 | //
7 | //
8 |
9 | #import "NSLayoutConstraint+OVConstructors.h"
10 |
11 | @implementation NSLayoutConstraint (OVConstructors)
12 |
13 | /////////////////////////////////////////////////////////////////////////
14 | #pragma mark - Centering
15 | /////////////////////////////////////////////////////////////////////////
16 |
17 | + (instancetype)constraintWithItemVerticallyCenteredInSuperview:(UIView *)aView
18 | {
19 | return [NSLayoutConstraint constraintWithItem:aView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:aView.superview attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
20 | }
21 |
22 | //---------------------------------------------------------------------
23 |
24 | + (instancetype)constraintWithItemHorizontallyCenteredInSuperview:(UIView *)aView
25 | {
26 | return [NSLayoutConstraint constraintWithItem:aView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:aView.superview attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
27 | }
28 |
29 | //---------------------------------------------------------------------
30 |
31 | + (NSArray *)constraintsWithItemCenteredInSuperview:(UIView *)aView
32 | {
33 | return @[
34 | [self constraintWithItemHorizontallyCenteredInSuperview:aView],
35 | [self constraintWithItemVerticallyCenteredInSuperview:aView]
36 | ];
37 | }
38 |
39 | /////////////////////////////////////////////////////////////////////////
40 | #pragma mark - Alignment
41 | /////////////////////////////////////////////////////////////////////////
42 |
43 | + (NSArray *)constraintsForAligningAttribute:(NSLayoutAttribute)attribute ofItems:(NSArray *)items
44 | {
45 | NSMutableArray *constraints = [NSMutableArray array];
46 |
47 | for (int i=0; i
9 | #define HC_SHORTHAND
10 | #import
11 | #import "NSDictionary+OVSelector.h"
12 |
13 | @interface NSDictionary_SelectorTest : SenTestCase
14 | {
15 | NSDictionary *JSON;
16 | }
17 | @end
18 |
19 | // {
20 | // "number" : 1,
21 | // "string" : "string",
22 | // "type" : 3,
23 | // "bool" : true,
24 | // "object" : {
25 | // "k" : "v"
26 | // },
27 | // "array" : [1,2,3],
28 | // "timestamp" : 1360000000,
29 | // "date8601" : "2013/01/01 12:24:36 +0900"
30 | // }
31 |
32 | static NSString *Dic_SelectorJSONString = @"{ \"number\" : 1, \"string\" : \"string\", \"type\" : 3, \"bool\" : true, \"object\" : { \"k\" : \"v\" }, \"array\" : [1,2,3], \"timestamp\" : 1360000000, \"date8601\" : \"2013/01/01 12:24:36 +0900\"}";
33 |
34 | @implementation NSDictionary_SelectorTest
35 |
36 |
37 | - (void)setUp {
38 | // Run before each test method
39 | JSON = [NSJSONSerialization JSONObjectWithData:[Dic_SelectorJSONString dataUsingEncoding:NSUTF8StringEncoding]
40 | options:NSJSONReadingAllowFragments
41 | error:nil];
42 |
43 | }
44 |
45 | - (void)tearDown {
46 | // Run after each test method
47 | }
48 |
49 | - (void)testObjectForKeyTransformBlock {
50 | NSDate *date = [JSON objectForKey:@"date8601" transformBlock:^id(id obj) {
51 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
52 | [formatter setDateFormat:@"yyyy/MM/dd HH:mm:ss Z"];
53 | return [formatter dateFromString:obj];
54 | }];
55 | assertThatLongLong([date timeIntervalSince1970], equalToLongLong(1357010676));
56 | }
57 |
58 | - (void)testStringForKey {
59 |
60 | assertThat([JSON stringForKey:@"string"], equalTo(@"string"));
61 | }
62 |
63 | - (void)testNumberForKey {
64 |
65 | assertThat([JSON numberForKey:@"number"], equalTo(@1));
66 | }
67 |
68 | - (void)testArrayForKey {
69 |
70 | assertThat([JSON arrayForKey:@"array"], equalTo(@[@1,@2,@3]));
71 | }
72 |
73 | - (void)testDictionaryForKey {
74 | assertThat([JSON dictionaryForKey:@"object"], equalTo(@{
75 | @"k" : @"v"
76 | }));
77 | }
78 |
79 | - (void)testDateForKey {
80 | NSDate *date = [JSON dateForKey:@"date8601"];
81 | assertThatLongLong([date timeIntervalSince1970], equalToLongLong(1357010676));
82 | }
83 |
84 | - (void)testDateForKeyUsingFormat {
85 | NSDate *date = [JSON dateForKey:@"date8601" usingFormat:@"yyyy/MM/dd HH:mm:ss Z"];
86 | assertThatLongLong([date timeIntervalSince1970], equalToLongLong(1357010676));
87 | }
88 |
89 | - (void)testDateWithTimestampForKey {
90 | NSDate *date = [JSON timestampForKey:@"timestamp"];
91 | assertThat(date, equalTo([NSDate dateWithTimeIntervalSince1970:1360000000]));
92 | }
93 |
94 | - (void)testBoolObjectWithTrueValue {
95 | assertThatBool([[JSON boolObjectForKey:@"type" withTrueValue:@3] boolValue], equalToBool(YES));
96 | }
97 |
98 |
99 | - (void)testBoolWithTrueValue {
100 | assertThatBool([JSON boolForKey:@"type" withTureValue:@3], equalToBool(YES));
101 | }
102 |
103 | - (void)testBool {
104 | assertThatBool([@{@"k" : @YES} boolForKey:@"k"], equalToBool(YES));
105 | }
106 |
107 | - (void)testInt {
108 |
109 | assertThatInt([@{@"k" : @2} intForKey:@"k"], equalToInt(2));
110 | }
111 |
112 | - (void)testInteger {
113 |
114 | assertThatInteger([@{@"k" : @2147483647} integerForKey:@"k"], equalToInteger(2147483647));
115 | }
116 |
117 | - (void)testUnsignedInt {
118 |
119 | assertThatUnsignedInt([@{@"k" : @2} unsignedIntForKey:@"k"], equalToUnsignedInt(2));
120 | }
121 |
122 | - (void)testUnsignedInteger {
123 |
124 | assertThatUnsignedInteger([@{@"k" : @4294967295} unsignedIntegerForKey:@"k"], equalToUnsignedInteger(4294967295));
125 | }
126 |
127 | - (void)testLong {
128 |
129 | assertThatLong([@{@"k" : @2147483647} longForKey:@"k"], equalToLong(2147483647));
130 | }
131 |
132 | - (void)testUnsignedLong {
133 |
134 | assertThatUnsignedLong([@{@"k" : @4294967295} unsignedLongForKey:@"k"], equalToUnsignedLong(4294967295));
135 | }
136 |
137 | - (void)testLongLong {
138 |
139 | assertThatLongLong([@{@"k" : @9223372036854775807} longLongForKey:@"k"], equalToLongLong(9223372036854775807));
140 | }
141 |
142 | - (void)testUnsignedLongLong {
143 |
144 | assertThatUnsignedLongLong([@{@"k" : @18446744073709551615} unsignedLongLongForKey:@"k"], equalToUnsignedLongLong(18446744073709551615));
145 | }
146 |
147 | - (void)testDouble {
148 |
149 | assertThatDouble([@{@"k" : @0.5} doubleForKey:@"k"], equalToDouble(0.5));
150 | }
151 |
152 | - (void)testFloat {
153 |
154 | assertThatFloat([@{@"k" : @0.5} floatForKey:@"k"], equalToFloat(0.5));
155 | }
156 |
157 |
158 | @end
159 |
--------------------------------------------------------------------------------
/OverlineTests/NSString/NSString+RegularExpressionTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSString+RegularExpressionTest.m
3 | // Copyright 2012 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 | #import "NSString+OVRegularExpression.h"
12 |
13 | @interface NSString_RegularExpressionTest : SenTestCase
14 | {
15 |
16 | }
17 | @end
18 |
19 | @implementation NSString_RegularExpressionTest
20 |
21 |
22 | - (void)testRangeOfFirstMatchInString
23 | {
24 | NSRange range = [@"hoge" rangeOfFirstMatchInString:@"fuga-hoge-fuga"];
25 | assertThatInteger(range.location, equalToInteger(5));
26 | assertThatInteger(range.length, equalToInteger(4));
27 |
28 | range = [@"h[0-9]ge" rangeOfFirstMatchInString:@"fuga-hoge-h0ge-fuga"];
29 | assertThatInteger(range.location, equalToInteger(10));
30 | assertThatInteger(range.length, equalToInteger(4));
31 |
32 | range = [@"h[A-Z]ge" rangeOfFirstMatchInString:@"fuga-hoge-fuga"];
33 | assertThatInteger(range.location, equalToInteger(NSNotFound));
34 | }
35 |
36 | - (void)testRangeOfFirstMatchInStringOptions
37 | {
38 | NSRange range = [@"hoge" rangeOfFirstMatchInString:@"fuga-hoge-fuga" options:NSRegularExpressionSearch];
39 | assertThatInteger(range.location, equalToInteger(5));
40 | assertThatInteger(range.length, equalToInteger(4));
41 |
42 | range = [@"h[0-9]ge" rangeOfFirstMatchInString:@"fuga-hoge-h0ge-fuga" options:NSRegularExpressionSearch];
43 | assertThatInteger(range.location, equalToInteger(10));
44 | assertThatInteger(range.length, equalToInteger(4));
45 |
46 | range = [@"h[A-Z]ge" rangeOfFirstMatchInString:@"fuga-hoge-fuga" options:NSRegularExpressionSearch];
47 | assertThatInteger(range.location, equalToInteger(NSNotFound));
48 | }
49 |
50 | - (void)testMatchesInString
51 | {
52 | NSArray *matches = [@"hoge" matchesInString:@"hoge-fuga-hoge"];
53 | assertThatInteger([matches count], equalToInteger(2));
54 | assertThat(matches, equalTo(@[@"hoge", @"hoge"]));
55 |
56 | matches = [@"h[0-9]ge" matchesInString:@"hoge-fuga-h0ge"];
57 | assertThatInteger([matches count], equalToInteger(1));
58 | assertThat(matches, equalTo(@[@"h0ge"]));
59 |
60 | matches = [@"h[A-Z]ge" matchesInString:@"fuga-hoge-fuga"];
61 | assertThatInteger([matches count], equalToInteger(0));
62 | }
63 |
64 | - (void)testMatchesInStringOptions
65 | {
66 | NSArray *matches = [@"hoge" matchesInString:@"hoge-fuga-hoge" options:NSRegularExpressionSearch];
67 | assertThatInteger([matches count], equalToInteger(2));
68 | assertThat(matches, equalTo(@[@"hoge", @"hoge"]));
69 |
70 | matches = [@"h[0-9]ge" matchesInString:@"hoge-fuga-h0ge" options:NSRegularExpressionSearch];
71 | assertThatInteger([matches count], equalToInteger(1));
72 | assertThat(matches, equalTo(@[@"h0ge"]));
73 |
74 | matches = [@"h[A-Z]ge" matchesInString:@"fuga-hoge-fuga" options:NSRegularExpressionSearch];
75 | assertThatInteger([matches count], equalToInteger(0));
76 | }
77 |
78 | - (void)testTestInString
79 | {
80 | assertThatBool([@"hoge" testInString:@"fuga-hoge-fuga"], equalToBool(YES));
81 | assertThatBool([@"hoge" testInString:@"fuga-piyo-fuga"], equalToBool(NO));
82 |
83 | assertThatBool([@"h[0-9]ge" testInString:@"fuga-h0ge-fuga"], equalToBool(YES));
84 | assertThatBool([@"h[A-Z]ge" testInString:@"fuga-hoge-fuga"], equalToBool(NO));
85 |
86 | assertThatBool([@"https?" testInString:@"http://example.com"], equalToBool(YES));
87 | assertThatBool([@"https?" testInString:@"https://example.com"], equalToBool(YES));
88 | }
89 |
90 | - (void)testTestInStringOptions
91 | {
92 | assertThatBool([@"hoge" testInString:@"fuga-hoge-fuga" options:NSRegularExpressionSearch], equalToBool(YES));
93 | assertThatBool([@"hoge" testInString:@"fuga-piyo-fuga" options:NSRegularExpressionSearch], equalToBool(NO));
94 |
95 | assertThatBool([@"h[0-9]ge" testInString:@"fuga-h0ge-fuga" options:NSRegularExpressionSearch], equalToBool(YES));
96 | assertThatBool([@"h[A-Z]ge" testInString:@"fuga-hoge-fuga" options:NSRegularExpressionSearch], equalToBool(NO));
97 | }
98 |
99 | - (void)testReplaceNewString
100 | {
101 | assertThat([@"hoge" replace:@"ho" newString:@"fu"], equalTo(@"fuge"));
102 | assertThat([@"hoge" replace:@"h[a-z]" newString:@"fu"], equalTo(@"fuge"));
103 | }
104 |
105 | - (void)testStringByReplacingOccurrenceOfRegExpWithString
106 | {
107 | assertThat([@"hoge" stringByReplacingOccurrencesOfRegExpPattern:@"ho" withString:@"fu"], equalTo(@"fuge"));
108 | assertThat([@"hoge" stringByReplacingOccurrencesOfRegExpPattern:@"h[a-z]" withString:@"fu"], equalTo(@"fuge"));
109 | assertThat([@"hoge fuga" stringByReplacingOccurrencesOfRegExpPattern:@"hoge" withString:@"fuga"], equalTo(@"fuga fuga"));
110 | assertThat([@"hoge and hoge" stringByReplacingOccurrencesOfRegExpPattern:@"hoge" withString:@"fuga"], equalTo(@"fuga and fuga"));
111 | }
112 |
113 | - (void)testReplaceNewStringOptions
114 | {
115 | assertThat([@"HOGE" replace:@"ho" newString:@"fu" options:NSRegularExpressionCaseInsensitive], equalTo(@"fuGE"));
116 | assertThat([@"HOGE" replace:@"h[A-Z]" newString:@"fu" options:NSRegularExpressionCaseInsensitive], equalTo(@"fuGE"));
117 | }
118 |
119 | - (void)testStringByReplacingOccurrenceOfRegExpWithStringOptions
120 | {
121 | assertThat([@"HOGE" stringByReplacingOccurrencesOfRegExpPattern:@"ho" withString:@"fu" options:NSRegularExpressionCaseInsensitive], equalTo(@"fuGE"));
122 | assertThat([@"HOGE" stringByReplacingOccurrencesOfRegExpPattern:@"h[A-Z]" withString:@"fu" options:NSRegularExpressionCaseInsensitive], equalTo(@"fuGE"));
123 | assertThat([@"hoGE fuga" stringByReplacingOccurrencesOfRegExpPattern:@"hoge" withString:@"fuga" options:NSRegularExpressionCaseInsensitive], equalTo(@"fuga fuga"));
124 | assertThat([@"HOGE and hoge" stringByReplacingOccurrencesOfRegExpPattern:@"hoge" withString:@"fuga" options:NSRegularExpressionCaseInsensitive], equalTo(@"fuga and fuga"));
125 | }
126 |
127 | - (void)testReplaceTemplate
128 | {
129 | assertThat([@"hoge" replace:@"(.+)" withTemplate:@"$1"], equalTo(@"hoge"));
130 | }
131 |
132 | - (void)testStringByReplacingOccurrenceOfRegExpWithTemplate
133 | {
134 | assertThat([@"hoge" stringByReplacingOccurrencesOfRegExpPattern:@"(.+)" withTemplate:@"$1"], equalTo(@"hoge"));
135 | assertThat([@"hoge fuga" stringByReplacingOccurrencesOfRegExpPattern:@"(hoge) (fuga)" withTemplate:@"$2 $1"], equalTo(@"fuga hoge"));
136 | assertThat([@"hoge and hoge" stringByReplacingOccurrencesOfRegExpPattern:@"(.+) and (.+)" withTemplate:@"$1 $2"], equalTo(@"hoge hoge"));
137 | }
138 |
139 | - (void)testReplaceTemplateOptions
140 | {
141 | assertThat([@"HOGE" replace:@"(.+)" withTemplate:@"$1" options:NSRegularExpressionCaseInsensitive], equalTo(@"HOGE"));
142 | }
143 |
144 | - (void)testStringByReplacingOccurrenceOfRegExpWithTemplateOptions
145 | {
146 | assertThat([@"hoge" stringByReplacingOccurrencesOfRegExpPattern:@"(.+)" withTemplate:@"$1" options:NSRegularExpressionCaseInsensitive], equalTo(@"hoge"));
147 | assertThat([@"hoge fuga" stringByReplacingOccurrencesOfRegExpPattern:@"(HOGE) (FUGA)" withTemplate:@"$2 $1" options:NSRegularExpressionCaseInsensitive], equalTo(@"fuga hoge"));
148 | assertThat([@"hoge and hoge" stringByReplacingOccurrencesOfRegExpPattern:@"(.+) and (.+)" withTemplate:@"$1 $2" options:NSRegularExpressionCaseInsensitive], equalTo(@"hoge hoge"));
149 | }
150 |
151 | @end
152 |
--------------------------------------------------------------------------------
/Overline/UIKit/UIView/UIView+OVPositioning.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+OVPositioning.m
3 | // Lab-VC-Transitions
4 | //
5 | // Created by Hari Karam Singh on 25/05/2014.
6 | // Copyright (c) 2014 Air Craft. All rights reserved.
7 | //
8 |
9 | #import "UIView+OVPositioning.h"
10 |
11 | @implementation UIView (OVPositioning)
12 |
13 | /////////////////////////////////////////////////////////////////////////
14 | #pragma mark - Frame get/set shorthand
15 | /////////////////////////////////////////////////////////////////////////
16 |
17 | - (CGPoint)origin
18 | {
19 | return self.frame.origin;
20 | }
21 |
22 | //---------------------------------------------------------------------
23 |
24 | - (void)setOrigin:(CGPoint)origin
25 | {
26 | CGRect f = self.frame;
27 | f.origin = origin;
28 | self.frame = f;
29 | }
30 |
31 | //---------------------------------------------------------------------
32 |
33 | - (CGFloat)x
34 | {
35 | return self.origin.x;
36 | }
37 |
38 | //---------------------------------------------------------------------
39 |
40 | - (void)setX:(CGFloat)x
41 | {
42 | CGRect f = self.frame;
43 | f.origin.x = x;
44 | self.frame = f;
45 | }
46 |
47 | //---------------------------------------------------------------------
48 |
49 | - (CGFloat)y
50 | {
51 | return self.origin.y;
52 | }
53 |
54 | //---------------------------------------------------------------------
55 |
56 | - (void)setY:(CGFloat)y
57 | {
58 | CGRect f = self.frame;
59 | f.origin.y = y;
60 | self.frame = f;
61 | }
62 |
63 | //---------------------------------------------------------------------
64 |
65 | - (CGSize)size
66 | {
67 | return self.frame.size;
68 | }
69 |
70 | //---------------------------------------------------------------------
71 |
72 | - (void)setSize:(CGSize)size
73 | {
74 | CGRect f = self.frame;
75 | f.size = size;
76 | self.frame = f;
77 | }
78 |
79 | //---------------------------------------------------------------------
80 |
81 | - (CGFloat)width
82 | {
83 | return self.size.width;
84 | }
85 |
86 | //---------------------------------------------------------------------
87 |
88 | - (void)setWidth:(CGFloat)width
89 | {
90 | CGRect f = self.frame;
91 | f.size.width = width;
92 | self.frame = f;
93 | }
94 |
95 | //---------------------------------------------------------------------
96 |
97 | - (CGFloat)height
98 | {
99 | return self.size.height;
100 | }
101 |
102 | //---------------------------------------------------------------------
103 |
104 | - (void)setHeight:(CGFloat)height
105 | {
106 | CGRect f = self.frame;
107 | f.size.height = height;
108 | self.frame = f;
109 | }
110 |
111 | //---------------------------------------------------------------------
112 |
113 | - (CGFloat)centerX
114 | {
115 | return self.center.x;
116 | }
117 |
118 | //---------------------------------------------------------------------
119 |
120 | - (void)setCenterX:(CGFloat)centerX
121 | {
122 | self.center = CGPointMake(centerX, self.center.y);
123 | }
124 |
125 | //---------------------------------------------------------------------
126 |
127 | - (CGFloat)centerY
128 | {
129 | return self.center.y;
130 | }
131 |
132 | //---------------------------------------------------------------------
133 |
134 | - (void)setCenterY:(CGFloat)centerY
135 | {
136 | self.center = CGPointMake(self.center.x, centerY);
137 | }
138 |
139 |
140 | /////////////////////////////////////////////////////////////////////////
141 | #pragma mark - Bounds shorthand
142 | /////////////////////////////////////////////////////////////////////////
143 |
144 | - (CGSize)boundsSize
145 | {
146 | return self.bounds.size;
147 | }
148 |
149 | //---------------------------------------------------------------------
150 |
151 | - (void)setBoundsSize:(CGSize)size
152 | {
153 | CGRect bounds = self.bounds;
154 | bounds.size = size;
155 | self.bounds = bounds;
156 | }
157 |
158 | //---------------------------------------------------------------------
159 |
160 | - (CGFloat)boundsWidth
161 | {
162 | return self.boundsSize.width;
163 | }
164 |
165 | //---------------------------------------------------------------------
166 |
167 | - (void)setBoundsWidth:(CGFloat)width
168 | {
169 | CGRect bounds = self.bounds;
170 | bounds.size.width = width;
171 | self.bounds = bounds;
172 | }
173 |
174 | //---------------------------------------------------------------------
175 |
176 | - (CGFloat)boundsHeight
177 | {
178 | return self.boundsSize.height;
179 | }
180 |
181 | //---------------------------------------------------------------------
182 |
183 | - (void)setBoundsHeight:(CGFloat)height
184 | {
185 | CGRect bounds = self.bounds;
186 | bounds.size.height = height;
187 | self.bounds = bounds;
188 | }
189 |
190 |
191 | /////////////////////////////////////////////////////////////////////////
192 | #pragma mark - Additional setters
193 | /////////////////////////////////////////////////////////////////////////
194 |
195 | - (void)alignCenterHorizontally
196 | {
197 | if (!self.superview) [NSException raise:NSGenericException format:@"Superview must not be nil"];
198 | CGPoint center = self.center;
199 | center.x = self.superview.frame.size.width * 0.5;
200 | self.center = center;
201 | }
202 |
203 | //---------------------------------------------------------------------
204 |
205 | - (void)alignCenterVertically
206 | {
207 | if (!self.superview) [NSException raise:NSGenericException format:@"Superview must not be nil"];
208 | CGPoint center = self.center;
209 | center.y = self.superview.frame.size.height * 0.5;
210 | self.center = center;
211 | }
212 |
213 | //---------------------------------------------------------------------
214 |
215 | - (void)alignCenter
216 | {
217 | if (!self.superview) [NSException raise:NSGenericException format:@"Superview must not be nil"];
218 | CGPoint center = self.center;
219 | center.x = self.superview.frame.size.width * 0.5;
220 | center.y = self.superview.frame.size.height * 0.5;
221 | self.center = center;
222 | }
223 |
224 | //---------------------------------------------------------------------
225 |
226 | - (void)alignRight
227 | {
228 | if (!self.superview) [NSException raise:NSGenericException format:@"Superview must not be nil"];
229 | CGRect frame = self.frame;
230 | frame.origin.x = self.superview.frame.size.width - frame.size.width;
231 | self.frame = frame;
232 | }
233 |
234 | //---------------------------------------------------------------------
235 |
236 | - (void)alignBottom
237 | {
238 | if (!self.superview) [NSException raise:NSGenericException format:@"Superview must not be nil"];
239 | CGRect frame = self.frame;
240 | frame.origin.y = self.superview.frame.size.height - frame.size.height;
241 | self.frame = frame;
242 | }
243 |
244 | //---------------------------------------------------------------------
245 |
246 |
247 | - (void)setMargins:(UIEdgeInsets)margins
248 | {
249 | if (!self.superview) [NSException raise:NSGenericException format:@"Superview must not be nil"];
250 | CGSize superSize = self.superview.frame.size;
251 | self.frame = CGRectMake(margins.left,
252 | margins.top,
253 | superSize.width - (margins.left + margins.right),
254 | superSize.height - (margins.top + margins.bottom));
255 | }
256 |
257 | //---------------------------------------------------------------------
258 |
259 | - (void)setBottomMargin:(CGFloat)bottom
260 | {
261 | if (!self.superview) [NSException raise:NSGenericException format:@"Superview must not be nil"];
262 | CGRect f = self.frame;
263 | f.origin.y = self.superview.frame.size.height - self.frame.size.height - bottom;
264 | self.frame = f;
265 | }
266 |
267 |
268 | @end
269 |
--------------------------------------------------------------------------------
/OverlineTests/NSString/NSString+RegularExpressionTestWithCpp.mm:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSString+RegularExpressionTestWithCpp.m
3 | // Copyright 2013 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 | #import "NSString+OVRegularExpression.h"
12 |
13 | @interface NSString_RegularExpressionTestWithCpp : SenTestCase
14 | {
15 |
16 | }
17 | @end
18 |
19 | @implementation NSString_RegularExpressionTestWithCpp
20 |
21 | namespace OverlineCpp {
22 | template
23 | class Test
24 | {
25 | public:
26 | template void fn(T &x) {
27 | }
28 | };
29 | }
30 |
31 | - (void)setUp {
32 | // Run before each test method
33 | }
34 |
35 | - (void)tearDown {
36 | // Run after each test method
37 | }
38 | - (void)testRangeOfFirstMatchInString
39 | {
40 | NSRange range = [@"hoge" rangeOfFirstMatchInString:@"fuga-hoge-fuga"];
41 | assertThatInteger(range.location, equalToInteger(5));
42 | assertThatInteger(range.length, equalToInteger(4));
43 |
44 | range = [@"h[0-9]ge" rangeOfFirstMatchInString:@"fuga-hoge-h0ge-fuga"];
45 | assertThatInteger(range.location, equalToInteger(10));
46 | assertThatInteger(range.length, equalToInteger(4));
47 |
48 | range = [@"h[A-Z]ge" rangeOfFirstMatchInString:@"fuga-hoge-fuga"];
49 | assertThatInteger(range.location, equalToInteger(NSNotFound));
50 | }
51 |
52 | - (void)testRangeOfFirstMatchInStringOptions
53 | {
54 | NSRange range = [@"hoge" rangeOfFirstMatchInString:@"fuga-hoge-fuga" options:NSRegularExpressionSearch];
55 | assertThatInteger(range.location, equalToInteger(5));
56 | assertThatInteger(range.length, equalToInteger(4));
57 |
58 | range = [@"h[0-9]ge" rangeOfFirstMatchInString:@"fuga-hoge-h0ge-fuga" options:NSRegularExpressionSearch];
59 | assertThatInteger(range.location, equalToInteger(10));
60 | assertThatInteger(range.length, equalToInteger(4));
61 |
62 | range = [@"h[A-Z]ge" rangeOfFirstMatchInString:@"fuga-hoge-fuga" options:NSRegularExpressionSearch];
63 | assertThatInteger(range.location, equalToInteger(NSNotFound));
64 | }
65 |
66 | - (void)testMatchesInString
67 | {
68 | NSArray *matches = [@"hoge" matchesInString:@"hoge-fuga-hoge"];
69 | assertThatInteger([matches count], equalToInteger(2));
70 | assertThat(matches, equalTo(@[@"hoge", @"hoge"]));
71 |
72 | matches = [@"h[0-9]ge" matchesInString:@"hoge-fuga-h0ge"];
73 | assertThatInteger([matches count], equalToInteger(1));
74 | assertThat(matches, equalTo(@[@"h0ge"]));
75 |
76 | matches = [@"h[A-Z]ge" matchesInString:@"fuga-hoge-fuga"];
77 | assertThatInteger([matches count], equalToInteger(0));
78 | }
79 |
80 | - (void)testMatchesInStringOptions
81 | {
82 | NSArray *matches = [@"hoge" matchesInString:@"hoge-fuga-hoge" options:NSRegularExpressionSearch];
83 | assertThatInteger([matches count], equalToInteger(2));
84 | assertThat(matches, equalTo(@[@"hoge", @"hoge"]));
85 |
86 | matches = [@"h[0-9]ge" matchesInString:@"hoge-fuga-h0ge" options:NSRegularExpressionSearch];
87 | assertThatInteger([matches count], equalToInteger(1));
88 | assertThat(matches, equalTo(@[@"h0ge"]));
89 |
90 | matches = [@"h[A-Z]ge" matchesInString:@"fuga-hoge-fuga" options:NSRegularExpressionSearch];
91 | assertThatInteger([matches count], equalToInteger(0));
92 | }
93 |
94 | - (void)testTestInString
95 | {
96 | assertThatBool([@"hoge" testInString:@"fuga-hoge-fuga"], equalToBool(YES));
97 | assertThatBool([@"hoge" testInString:@"fuga-piyo-fuga"], equalToBool(NO));
98 |
99 | assertThatBool([@"h[0-9]ge" testInString:@"fuga-h0ge-fuga"], equalToBool(YES));
100 | assertThatBool([@"h[A-Z]ge" testInString:@"fuga-hoge-fuga"], equalToBool(NO));
101 |
102 | assertThatBool([@"https?" testInString:@"http://example.com"], equalToBool(YES));
103 | assertThatBool([@"https?" testInString:@"https://example.com"], equalToBool(YES));
104 | }
105 |
106 | - (void)testTestInStringOptions
107 | {
108 | assertThatBool([@"hoge" testInString:@"fuga-hoge-fuga" options:NSRegularExpressionSearch], equalToBool(YES));
109 | assertThatBool([@"hoge" testInString:@"fuga-piyo-fuga" options:NSRegularExpressionSearch], equalToBool(NO));
110 |
111 | assertThatBool([@"h[0-9]ge" testInString:@"fuga-h0ge-fuga" options:NSRegularExpressionSearch], equalToBool(YES));
112 | assertThatBool([@"h[A-Z]ge" testInString:@"fuga-hoge-fuga" options:NSRegularExpressionSearch], equalToBool(NO));
113 | }
114 |
115 | - (void)testReplaceNewString
116 | {
117 | assertThat([@"hoge" replace:@"ho" newString:@"fu"], equalTo(@"fuge"));
118 | assertThat([@"hoge" replace:@"h[a-z]" newString:@"fu"], equalTo(@"fuge"));
119 | }
120 |
121 | - (void)testStringByReplacingOccurrenceOfRegExpWithString
122 | {
123 | assertThat([@"hoge" stringByReplacingOccurrencesOfRegExpPattern:@"ho" withString:@"fu"], equalTo(@"fuge"));
124 | assertThat([@"hoge" stringByReplacingOccurrencesOfRegExpPattern:@"h[a-z]" withString:@"fu"], equalTo(@"fuge"));
125 | assertThat([@"hoge fuga" stringByReplacingOccurrencesOfRegExpPattern:@"hoge" withString:@"fuga"], equalTo(@"fuga fuga"));
126 | assertThat([@"hoge and hoge" stringByReplacingOccurrencesOfRegExpPattern:@"hoge" withString:@"fuga"], equalTo(@"fuga and fuga"));
127 | }
128 |
129 | - (void)testReplaceNewStringOptions
130 | {
131 | assertThat([@"HOGE" replace:@"ho" newString:@"fu" options:NSRegularExpressionCaseInsensitive], equalTo(@"fuGE"));
132 | assertThat([@"HOGE" replace:@"h[A-Z]" newString:@"fu" options:NSRegularExpressionCaseInsensitive], equalTo(@"fuGE"));
133 | }
134 |
135 | - (void)testStringByReplacingOccurrenceOfRegExpWithStringOptions
136 | {
137 | assertThat([@"HOGE" stringByReplacingOccurrencesOfRegExpPattern:@"ho" withString:@"fu" options:NSRegularExpressionCaseInsensitive], equalTo(@"fuGE"));
138 | assertThat([@"HOGE" stringByReplacingOccurrencesOfRegExpPattern:@"h[A-Z]" withString:@"fu" options:NSRegularExpressionCaseInsensitive], equalTo(@"fuGE"));
139 | assertThat([@"hoGE fuga" stringByReplacingOccurrencesOfRegExpPattern:@"hoge" withString:@"fuga" options:NSRegularExpressionCaseInsensitive], equalTo(@"fuga fuga"));
140 | assertThat([@"HOGE and hoge" stringByReplacingOccurrencesOfRegExpPattern:@"hoge" withString:@"fuga" options:NSRegularExpressionCaseInsensitive], equalTo(@"fuga and fuga"));
141 | }
142 |
143 | - (void)testReplaceTemplate
144 | {
145 | assertThat([@"hoge" replace:@"(.+)" withTemplate:@"$1"], equalTo(@"hoge"));
146 | }
147 |
148 | - (void)testStringByReplacingOccurrenceOfRegExpWithTemplate
149 | {
150 | assertThat([@"hoge" stringByReplacingOccurrencesOfRegExpPattern:@"(.+)" withTemplate:@"$1"], equalTo(@"hoge"));
151 | assertThat([@"hoge fuga" stringByReplacingOccurrencesOfRegExpPattern:@"(hoge) (fuga)" withTemplate:@"$2 $1"], equalTo(@"fuga hoge"));
152 | assertThat([@"hoge and hoge" stringByReplacingOccurrencesOfRegExpPattern:@"(.+) and (.+)" withTemplate:@"$1 $2"], equalTo(@"hoge hoge"));
153 | }
154 |
155 | - (void)testReplaceTemplateOptions
156 | {
157 | assertThat([@"HOGE" replace:@"(.+)" withTemplate:@"$1" options:NSRegularExpressionCaseInsensitive], equalTo(@"HOGE"));
158 | }
159 |
160 | - (void)testStringByReplacingOccurrenceOfRegExpWithTemplateOptions
161 | {
162 | assertThat([@"hoge" stringByReplacingOccurrencesOfRegExpPattern:@"(.+)" withTemplate:@"$1" options:NSRegularExpressionCaseInsensitive], equalTo(@"hoge"));
163 | assertThat([@"hoge fuga" stringByReplacingOccurrencesOfRegExpPattern:@"(HOGE) (FUGA)" withTemplate:@"$2 $1" options:NSRegularExpressionCaseInsensitive], equalTo(@"fuga hoge"));
164 | assertThat([@"hoge and hoge" stringByReplacingOccurrencesOfRegExpPattern:@"(.+) and (.+)" withTemplate:@"$1 $2" options:NSRegularExpressionCaseInsensitive], equalTo(@"hoge hoge"));
165 | }
166 |
167 | @end
168 |
--------------------------------------------------------------------------------
/OverlineTests/NSDictionary/NSDictionary+EnumerationTest.m:
--------------------------------------------------------------------------------
1 | //
2 | // Overline - NSDictionary+EnumerationTest.m
3 | // Copyright 2012 __MyCompanyName__. All rights reserved.
4 | //
5 | // Created by: yaakaito
6 | //
7 |
8 | #import
9 | #define HC_SHORTHAND
10 | #import
11 |
12 | #import "NSDictionary+OVEnumeration.h"
13 | #import "NSDictionary+OVCore.h"
14 | #import "NSString+OVRegularExpression.h"
15 |
16 |
17 | @interface NSDictionary_EnumerationTest : SenTestCase
18 | {
19 |
20 | }
21 | @end
22 |
23 | @implementation NSDictionary_EnumerationTest
24 |
25 | - (void)testEach {
26 | __block NSUInteger count = 0;
27 | NSDictionary *dic = @{
28 | @"a" : @1,
29 | @"b" : @2,
30 | @"c" : @3
31 | };
32 |
33 | [dic each:^(id obj, NSString *key) {
34 | assertThat(obj, equalTo([dic objectForKey:key]));
35 | count++;
36 | }];
37 |
38 | assertThatInteger(count, equalToInteger(3));
39 | }
40 |
41 | - (void)testMap {
42 | NSDictionary *dic = @{
43 | @"a" : @1,
44 | @"b" : @2,
45 | @"c" : @3,
46 | @"d" : @4
47 | };
48 |
49 | NSDictionary *mapped = [dic map:^(id obj, NSString *key) {
50 | return @([obj integerValue] * 2);
51 | }];
52 |
53 | assertThat(mapped, equalTo(@{@"a":@2,@"b":@4,@"c":@6,@"d":@8}));
54 | }
55 |
56 | - (void)testMappedDictionary {
57 | NSDictionary *dic = @{
58 | @"a" : @1,
59 | @"b" : @2,
60 | @"c" : @3,
61 | @"d" : @4
62 | };
63 |
64 | NSDictionary *mapped = [dic mappedDictionaryUsingBlock:^(id obj, NSString *key) {
65 | return @([obj integerValue] * 2);
66 | }];
67 |
68 | assertThat(mapped, equalTo(@{@"a":@2,@"b":@4,@"c":@6,@"d":@8}));
69 | }
70 |
71 | - (void)testArrayMap {
72 | NSDictionary *dic = @{
73 | @"a" : @1,
74 | @"b" : @2,
75 | @"c" : @3,
76 | @"d" : @4
77 | };
78 |
79 | NSArray *mapped = [dic mappedArrayUsingBlock:^(id obj, NSString *key) {
80 | return @([obj integerValue] * 2);
81 | }];
82 |
83 | assertThat([mapped sortedArrayUsingSelector:@selector(compare:)], equalTo(@[@2,@4,@6,@8]));
84 | }
85 |
86 |
87 | - (void)testFilterKey {
88 | NSDictionary *dic = @{
89 | @"a" : @1,
90 | @"b" : @2,
91 | @"c" : @3,
92 | @"d" : @4
93 | };
94 |
95 | NSDictionary *filtered = [dic filterKey:^BOOL(NSString *key) {
96 | return [key isEqualToString:@"a"];
97 | }];
98 | assertThat(filtered, equalTo(@{@"a":@1}));
99 | }
100 |
101 | - (void)testDictionaryFilteredByKey {
102 | NSDictionary *dic = @{
103 | @"a" : @1,
104 | @"b" : @2,
105 | @"c" : @3,
106 | @"d" : @4
107 | };
108 |
109 | NSDictionary *filtered = [dic dictionaryFilteredByKeyUsingBlock:^BOOL(NSString *key) {
110 | return [key isEqualToString:@"a"];
111 | }];
112 | assertThat(filtered, equalTo(@{@"a":@1}));
113 | }
114 |
115 | - (void)testRejectKey {
116 | NSDictionary *dic = @{
117 | @"a" : @1,
118 | @"b" : @2,
119 | @"c" : @3,
120 | @"d" : @4
121 | };
122 |
123 | NSDictionary *rejected = [dic rejectKey:^BOOL(NSString *key) {
124 | return [key isEqualToString:@"a"];
125 | }];
126 | assertThat(rejected, equalTo(@{@"b":@2, @"c":@3, @"d":@4}));
127 | }
128 |
129 | - (void)testDictionaryRejectedByKey {
130 | NSDictionary *dic = @{
131 | @"a" : @1,
132 | @"b" : @2,
133 | @"c" : @3,
134 | @"d" : @4
135 | };
136 |
137 | NSDictionary *rejected = [dic dictionaryRejectedByKeyUsingBlock:^BOOL(NSString *key) {
138 | return [key isEqualToString:@"a"];
139 | }];
140 | assertThat(rejected, equalTo(@{@"b":@2, @"c":@3, @"d":@4}));
141 | }
142 |
143 |
144 | - (void)testFilterObject{
145 | NSDictionary *dic = @{
146 | @"a" : @1,
147 | @"b" : @2,
148 | @"c" : @3,
149 | @"d" : @4
150 | };
151 |
152 | NSDictionary *filtered = [dic filterObject:^BOOL(id obj) {
153 | return [obj integerValue] == 1;
154 | }];
155 | assertThat(filtered, equalTo(@{@"a":@1}));
156 | }
157 |
158 | - (void)testDictionaryFilteredByObject {
159 | NSDictionary *dic = @{
160 | @"a" : @1,
161 | @"b" : @2,
162 | @"c" : @3,
163 | @"d" : @4
164 | };
165 |
166 | NSDictionary *filtered = [dic dictionaryFilteredByObjectUsingBlock:^BOOL(id obj) {
167 | return [obj integerValue] == 1;
168 | }];
169 | assertThat(filtered, equalTo(@{@"a":@1}));
170 | }
171 |
172 | - (void)testRejectObject {
173 | NSDictionary *dic = @{
174 | @"a" : @1,
175 | @"b" : @2,
176 | @"c" : @3,
177 | @"d" : @4
178 | };
179 |
180 | NSDictionary *rejected = [dic rejectObject:^BOOL(id obj) {
181 | return [obj integerValue] == 1;
182 | }];
183 | assertThat(rejected, equalTo(@{@"b":@2, @"c":@3, @"d":@4}));
184 | }
185 |
186 | - (void)testDictionaryRejectedByObject {
187 | NSDictionary *dic = @{
188 | @"a" : @1,
189 | @"b" : @2,
190 | @"c" : @3,
191 | @"d" : @4
192 | };
193 |
194 | NSDictionary *rejected = [dic dictionaryRejectedByObjectUsingBlock:^BOOL(id obj) {
195 | return [obj integerValue] == 1;
196 | }];
197 | assertThat(rejected, equalTo(@{@"b":@2, @"c":@3, @"d":@4}));
198 | }
199 |
200 | - (void)testMerge {
201 | NSDictionary *left = @{ @"left" : @"left-value" , @"ov" : @"left" };
202 | NSDictionary *right = @{ @"right" : @"right-value" , @"ov" : @"right"};
203 | NSDictionary *expect = @{
204 | @"left" : @"left-value",
205 | @"right" : @"right-value",
206 | @"ov" : @"right"
207 | };
208 |
209 | assertThat([left merge:right], equalTo(expect));
210 | }
211 |
212 | - (void)testDictionaryByMergingDictionary {
213 | NSDictionary *left = @{ @"left" : @"left-value" , @"ov" : @"left" };
214 | NSDictionary *right = @{ @"right" : @"right-value" , @"ov" : @"right"};
215 | NSDictionary *expect = @{
216 | @"left" : @"left-value",
217 | @"right" : @"right-value",
218 | @"ov" : @"right"
219 | };
220 |
221 | assertThat([left dictionaryByMergingDictionary:right], equalTo(expect));
222 | }
223 |
224 | - (void)testReduce {
225 | NSDictionary *dic = @{
226 | @"k1" : @"v1",
227 | @"k2" : @"k2"
228 | };
229 |
230 | NSString *actual = [dic reduce:^id(id memo, id obj, NSString *key) {
231 | return [memo stringByAppendingFormat:@"%@=%@", key, obj];
232 | } memo:@"hoge"];
233 |
234 | assertThat(actual, containsString(@"k1=v1"));
235 | assertThat(actual, containsString(@"k2=k2"));
236 |
237 | assertThatBool([@"hoge.{2}=.{2}.{2}=.{2}" testInString:actual], equalToBool(YES));
238 | }
239 |
240 | - (void)testReducedObjectUsingBlock {
241 | NSDictionary *dic = @{
242 | @"k1" : @"v1",
243 | @"k2" : @"k2"
244 | };
245 |
246 | NSString *actual = [dic reducedObjectUsingBlock:^id(id memo, id obj, NSString *key) {
247 | return [memo stringByAppendingFormat:@"%@=%@", key, obj];
248 | } memo:@"hoge"];
249 |
250 | assertThat(actual, containsString(@"k1=v1"));
251 | assertThat(actual, containsString(@"k2=k2"));
252 |
253 | assertThatBool([@"hoge.{2}=.{2}.{2}=.{2}" testInString:actual], equalToBool(YES));
254 | }
255 |
256 | - (void)testQueryString {
257 | NSDictionary *dic = @{
258 | @"k1" : @"v1",
259 | @"k2" : @"k2"
260 | };
261 |
262 | NSString *actual = [dic queryString];
263 |
264 | assertThat(actual, containsString(@"k1=v1"));
265 | assertThat(actual, containsString(@"k2=k2"));
266 |
267 | assertThatBool([@".{2}=.{2}&.{2}=.{2}" testInString:actual], equalToBool(YES));
268 | }
269 |
270 | - (void)testStringByFormattingQuery {
271 | NSDictionary *dic = @{
272 | @"k1" : @"v1",
273 | @"k2" : @"k2"
274 | };
275 |
276 | NSString *actual = [dic stringByFormattingQuery];
277 |
278 | assertThat(actual, containsString(@"k1=v1"));
279 | assertThat(actual, containsString(@"k2=k2"));
280 |
281 | assertThatBool([@".{2}=.{2}&.{2}=.{2}" testInString:actual], equalToBool(YES));
282 | }
283 | @end
284 |
--------------------------------------------------------------------------------
/README.mkd:
--------------------------------------------------------------------------------
1 | # Overline 0.2.0
2 |
3 | Objective-C utilities and shorthands.
4 |
5 | Overline is not clone of other language features.
6 | Simple and clean Objective-C.
7 |
8 | ## Usage
9 |
10 | setup with cocoapods.
11 | ```
12 | pod 'Overline'
13 | ```
14 |
15 | import `Overline.h`
16 | ```objective-c
17 | #import "Overline.h"
18 | ```
19 |
20 | ### with BlocksKit
21 |
22 | ```
23 | pod 'BlocksKit'
24 | pod 'Overline-BlocksKit'
25 | ```
26 |
27 | Ignored duplicate methods: `each` `map` `reduce` `filter` `reject`
28 |
29 | ## Features
30 |
31 | ### NSArray
32 |
33 | #### NSArray+Initialize
34 |
35 | ```objective-c
36 | NSArray *array = [NSArray arrayWithRangeFrom:0 to:10];
37 | // @[@0, @1, @2, @3, @4, @5, @6, @7, @8, @9]
38 |
39 | NSArray *array2 = [NSArray arrayWithRangeFrom:0 to:-10 step:2];
40 | // @[@0, @-2, @-4, @-6, @-8]
41 | ```
42 |
43 | * `arrayWithRangeFrom:to:`
44 | * `arrayWithRangeFrom:to:step:`
45 |
46 | #### NSArray+Enumeration
47 |
48 | ```objective-c
49 | NSArray *mapped = [@[@1,@2,@3,@4,@5,@6] mappedArrayUsingBlock:^id(id obj, NSUInteger idx) {
50 | if ([obj integerValue] % 2 == 0) {
51 | return obj;
52 | }
53 | return nil;
54 | }];
55 | // @[@2,@4,@6]
56 | ```
57 |
58 | * `each`
59 | * `map` `mappedArrayUsingBlock`
60 | * `reduce` `reducedObjectByBlock`
61 | * `find` `objectUsingBlock`
62 | * `filter` `filteredArrayUsingBlock`
63 | * `reject` `rejectedArrayUsingBlock`
64 |
65 | #### NSArray+Random
66 |
67 | ```objective-c
68 | NSArray *shuffled = [@[@1,@2,@3,@4,@5,@6] shuffledArray];
69 | ```
70 |
71 | * `shuffle` `shuffledArray`
72 | * `anyObject`
73 |
74 | #### NSArray+Reverse
75 |
76 | ```objective-c
77 | NSArray *reversed = [@[@1,@2,@3,@4,@5,@6] reversedArray];
78 | // @[@6,@5,@4,@3,@2,@1]
79 | ```
80 |
81 | * `reverse` `reversedArray`
82 | * `objectAtReversedIndex`
83 |
84 | #### NSArray+Selector
85 |
86 | * `firstObject`
87 |
88 | #### NSArray+SubArray
89 |
90 | * `subarrayFromIndex:`
91 | * `subarrayFromIndex:length:`
92 | * `subarrayToIndex:`
93 | * `uniqueObjects`
94 | * `uniqueObjectsUsingEqualsBlock`
95 |
96 | #### NSArray+Difference
97 |
98 | * `difference` `arrayDifferenceWithArray`
99 | * `unionise` `arrayByUnionisingArray`
100 |
101 | #### NSArray+Shorthand
102 |
103 | * `isEmpty`
104 |
105 |
106 | #### NSArray+Sorting
107 |
108 | * `arraySortedDescending:`
109 | * `arraySortedAsc`
110 | * `arraySortedDesc`
111 |
112 | ### NSMutableArray
113 | #### NSMutableArray+Shorthands
114 |
115 | ```objective-c
116 | NSMutableArray *marray = [NSMutableArray arrayWithArray:@[@1,@2,@3]];
117 | [marray insertObjects:@[@4,@5,@6] atIndex:1];
118 | ```
119 | * `insertObjects:atIndex:`
120 |
121 | #### NSMutableArray+Sorting
122 |
123 | * `sortDescending:`
124 | * `sortAsc`
125 | * `sortDesc`
126 |
127 | ### NSDate
128 |
129 | #### NSDate+Components
130 |
131 | ##### Class Methods
132 |
133 | * `currentWeekday`
134 | * `currentHour`
135 | * `currentMinute`
136 | * `currentSecond`
137 | * `currentDay`
138 | * `currentMonth`
139 | * `currentYear`
140 | * `commonDateComponentsForNow`
141 | * `timeComponentsForNow`
142 |
143 | ##### Instance Methods
144 |
145 | * `weekday`
146 | * `hour`
147 | * `minute`
148 | * `second`
149 | * `day`
150 | * `month`
151 | * `year`
152 | * `commonDateComponents`
153 | * `timeComponents`
154 |
155 |
156 | ### NSDictionary
157 |
158 | #### NSDictionary+Selector
159 |
160 | ```objective-c
161 | NSDate *date = [JSON objectForKey:@"date8601" transformBlock:^id(id obj) {
162 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
163 | [formatter setDateFormat:@"yyyy/MM/dd HH:mm:ss Z"];
164 | return [formatter dateFromString:obj];
165 | }];
166 | ```
167 |
168 | * `objectForKey:transformBlock:`
169 | * `numberForKey:`
170 | * `stringForKey:`
171 | * `arrayForKey:`
172 | * `dictionaryForKey:`
173 | * `dateForKey:`
174 | * `dateForKey:usingFormat:`
175 | * `since1970DateForKey:`
176 | * `timestampForKey:`
177 | * `boolObjectForKey:withTrueValue:`
178 | * `boolForKey:withTureValue:`
179 | * `boolForKey:`
180 | * `intForKey:`
181 | * `integerForKey:`
182 | * `unsignedIntForKey:`
183 | * `unsignedIntegerForKey:`
184 | * `longForKey:`
185 | * `unsignedLongForKey:`
186 | * `longLongForKey:`
187 | * `unsignedLongLongForKey:`
188 | * `doubleForKey:`
189 | * `floatForKey:`
190 |
191 | #### NSDictionary+Enumeration
192 |
193 | ```objective-c
194 | NSDictionary *dic = @{
195 | @"a" : @1,
196 | @"b" : @2,
197 | @"c" : @3,
198 | @"d" : @4
199 | };
200 |
201 | NSDictionary *filtered = [dic dictionaryFilteredByKeyUsingBlock:^BOOL(NSString *key) {
202 | return [key isEqualToString:@"a"];
203 | }]; // @{@"a":@1}
204 | ```
205 |
206 | * `each:`
207 | * `map` `mappedDictionaryUsingBlock`
208 | * `arrayMap` `mappedArrayUsingBlock`
209 | * `filterKey` `dictionaryFilteredByKeyUsingBlock`
210 | * `rejectKey` `dictionaryRejectedByKeyUsingBlock`
211 | * `filterObject` `dictionaryFilteredByObjectUsingBlock`
212 | * `rejectObject` `dictionaryRejectedByObjectUsingBlock`
213 | * `merge` `dictionaryByMergingDictionary`
214 | * `reduce:` `reducedObjectUsingBlock:memo:`
215 | * `queryString` `stringByFormattingQuery`
216 |
217 |
218 | #### NSDictionary+Path
219 |
220 | ```objective-c
221 | /*
222 | @{
223 | @"error" : @{
224 | @"message" : @"msg"
225 | }
226 | }
227 | */
228 | NSString *s = [dic objectForPath:@"error.message"];
229 | ```
230 |
231 | * `objectForPath:`
232 |
233 | ### NSSet
234 | #### NSSet+Enumeration
235 |
236 | ```objective-c
237 | NSSet *set = [NSSet setWithArray:@[@1,@2,@3,@4,@5,@6]];
238 | NSSet *mapped = [set mappedSetUsingBlock:^id(id obj, NSUInteger idx) {
239 | if ([obj integerValue] % 2 == 0) {
240 | return obj;
241 | }
242 | return nil;
243 | }];
244 | ```
245 |
246 | * `each`
247 | * `map` `mappedSetUsingBlock`
248 | * `reduce` `reducedObjectByBlock`
249 | * `filter` `filteredSetUsingBlock`
250 | * `reject` `rejectedSetUsingBlock`
251 |
252 | ### NSString
253 |
254 | #### NSString+Components
255 |
256 | ```objective-c
257 | [@"hoge=fuga&piyo=foo" componentsSeparatedByInnerString:@"=" andOuterString:@"&"];
258 | /*
259 | @{
260 | @"hoge" : @"fuga",
261 | @"piyo" : @"foo"
262 | };
263 | */
264 | ```
265 |
266 | * `componentsSeparatedByInnerString:andOuterString:`
267 |
268 | #### NSString+RegularExpression
269 |
270 | ```objective-c
271 | [@"https?" testInString:urlString];
272 | ```
273 | * `rangeOfFirstMatchInString:`
274 | * `rangeOfFirstMatchInString:options:`
275 | * `matchesInString:`
276 | * `matchesInString:options:`
277 | * `testInString:`
278 | * `testInString:options:`
279 | * `replace:newString:` `stringByReplacingOccurrencesOfRegExpPattern:withString`
280 | * `replace:newString:options:` `stringByReplacingOccurrencesOfRegExpPattern:withString:options:`
281 | * `replace:template:` `stringByReplacingOccurrencesOfRegExpPattern:withTemplate:`
282 | * `replace:template:options:` `stringByReplacingOccurrencesOfRegExpPattern:withTemplate:options:`
283 |
284 | #### NSString+Hash
285 |
286 | ```objective-c
287 | [@"hoge" md5]; // @"ea703e7aa1efda0064eaa507d9e8ab7e"
288 | ```
289 |
290 | * `sha256`
291 | * `stringByHashingSha256`
292 | * `md5`
293 | * `stringByHashingMD5`
294 |
295 | #### NSString+URLEncode
296 | * `URLEncode`
297 | * `stringByEncodingURL`
298 | * `URLDecode`
299 | * `stringByDecodingURL`
300 |
301 | #### NSString+Shorthand
302 | * `trim`
303 | * `trim:` - Trim character set in a given string
304 |
305 | #### NSString+JSON
306 | ```objective-c
307 | NSString *JSONString = @"{\"hoge\" : \"fuga\" }";
308 | id json = [JSONString jsonObject];
309 | ```
310 | * `JSON` `jsonObject`
311 |
312 | #### NSString+Base64Encode
313 | ```objective-c
314 | [@"a" stringByEncodingBase64]; // @"YQ=="
315 | [@"YQ==" stringByDecodingBase64]; // @"a"
316 | ```
317 |
318 | * `encodeBase64` `stringByEncodingBase64`
319 | * `decodeBase64` `stringByDecodingBase64`
320 | * `dataUsingDecodingBase64`
321 |
322 | ### NSData
323 | #### NSData+Base64Encode
324 |
325 | * `base64Encode` `stringUsingEncodingBase64`
326 |
327 | ### NSURL
328 |
329 | #### NSURL+Components
330 | * `queryComponents`
331 |
332 | #### NSURL+Directories
333 | ```objective-c
334 | NSURL *pdfURL = [NSURL URLForUserDirectoryWithAppendedPath:@"myDoc.pdf"];
335 | NSURL *userImageFolderURL = [NSURL URLForUserDirectoryWithAppendedPath:@"images"];
336 | ```
337 |
338 | * `URLForDirectory:domainMask:`
339 | * `URLForApplicationSupportDataDirectory`
340 | * `URLForApplicationSupportWithAppendedPath:`
341 | * `URLForUserDirectory`
342 | * `URLForUserDirectoryWithAppendedPath:`
343 | * `URLForDocumentDirectory`;
344 | * `URLForDocumentDirectoryWithAppendedPath:`;
345 |
346 | ### NSBundle
347 |
348 | #### NSBundle+Shorthand
349 | * `JSONForResourceName`
350 |
351 | ### NSNumber
352 |
353 | #### NSNumber+Equals
354 |
355 | ```objective-c
356 | [@1 isEqualToInteger:1];
357 | ```
358 |
359 | * `isEqualToInt:`
360 | * `isEqualToInteger:`
361 | * `isEqualToUnsignedInt:`
362 | * `isEqualToUnsignedInteger:`
363 | * `isEqualToLong:`
364 | * `isEqualToLongLong:`
365 | * `isEqualToUnsignedLong:`
366 | * `isEqualToUnsignedLongLong:`
367 | * `isEqualToDouble:`
368 | * `isEqualToFloat:`
369 |
370 | ### NSDateFormatter
371 |
372 | #### NSDateFormatter+Shothand
373 |
374 | * `userDefaultFormatter`
375 | * `dateFormatterWithCalendarIndetifiter:localeIdentifiter:timeZoneAbbreviation:`
376 |
377 | ### NSObject
378 |
379 | #### NSObject+Equals
380 | ```objective-c
381 | [[NSNull null] isNullObject]; // YES
382 | [[NSArray array] isNullObject]; // NO
383 | ```
384 | * `isNullObject`
385 | * `isArray`
386 | * `isDictionary`
387 | * `isSet`
388 | * `isString`
389 | * `isNumber`
390 |
391 | ### NSNull
392 |
393 | #### NSNull+Natural
394 | Provide `NSNull` like `nil`
395 | ```objective-c
396 | NSDictionary *dic = @{
397 | @"null-key" : [NSNull null]
398 | };
399 | [[dic objectForKey:@"null-key"] objectForKey:@"empty"]; // nil
400 | ```
401 |
402 | ※ This feature disable on default. Define `OV_USE_NATURAL_NULL`, if use this feature.
403 | ```objective-c
404 | #define OV_USE_NATURAL_NULL
405 | #import "Overline.h"
406 | ```
407 |
408 | ## Credits
409 |
410 | Be sure to thank these contributors:
411 |
412 | * Kazuma Ukyo (Creator, http://yaakaito.org)
413 | * Hari Karam Singh (Contributor, http://soundwandapp.com)
414 |
415 | ### Coding rules
416 |
417 | * Write tests.
418 | * Objective-C style naming.
419 | * and shorthands.
420 |
--------------------------------------------------------------------------------