17 #import <Foundation/Foundation.h>
18 #import <UIKit/UIKit.h>
20 #import "NIPreprocessorMacros.h"
22 #if defined __cplusplus
38 #pragma mark - NSInvocation Methods
54 #pragma mark - CGRect Methods
82 CGRect
NIRectExpand(CGRect rect, CGFloat dx, CGFloat dy);
92 CGRect
NIRectShift(CGRect rect, CGFloat dx, CGFloat dy);
107 CGFloat
NICenterX(CGSize containerSize, CGSize size);
114 CGFloat
NICenterY(CGSize containerSize, CGSize size);
131 #pragma mark - NSRange Methods
156 #pragma mark - NSData Methods
178 #pragma mark - NSString Methods
270 #pragma mark - CGFloat Methods
283 #if CGFLOAT_IS_DOUBLE
284 #define NI_CGFLOAT_EPSILON DBL_EPSILON
286 #define NI_CGFLOAT_EPSILON FLT_EPSILON
293 #if CGFLOAT_IS_DOUBLE
294 return (CGFloat)fabs(x);
296 return (CGFloat)fabsf(x);
304 #if CGFLOAT_IS_DOUBLE
305 return (CGFloat)floor(x);
307 return (CGFloat)floorf(x);
315 #if CGFLOAT_IS_DOUBLE
316 return (CGFloat)ceil(x);
318 return (CGFloat)ceilf(x);
326 #if CGFLOAT_IS_DOUBLE
327 return (CGFloat)round(x);
329 return (CGFloat)roundf(x);
337 #if CGFLOAT_IS_DOUBLE
338 return (CGFloat)sqrt(x);
340 return (CGFloat)sqrtf(x);
348 #if CGFLOAT_IS_DOUBLE
349 return (CGFloat)copysign(x, y);
351 return (CGFloat)copysignf(x, y);
359 #if CGFLOAT_IS_DOUBLE
360 return (CGFloat)pow(x, y);
362 return (CGFloat)powf(x, y);
370 #if CGFLOAT_IS_DOUBLE
371 return (CGFloat)cos(x);
373 return (CGFloat)cosf(x);
379 #pragma mark - General Purpose Methods
405 CGFloat
NIBoundf(CGFloat value, CGFloat min, CGFloat max);
414 NSInteger
NIBoundi(NSInteger value, NSInteger min, NSInteger max);
418 #if defined __cplusplus
NSRange NIMakeNSRangeFromCFRange(CFRange range)
Create an NSRange object from a CFRange object.
#define __NI_DEPRECATED_METHOD
Mark a method or property as deprecated to the compiler.
NSDictionary * NIQueryDictionaryFromStringUsingEncoding(NSString *string, NSStringEncoding encoding)
Parses a URL query string into a dictionary where the values are arrays.
NSString * NIMD5HashFromData(NSData *data)
Calculates an md5 hash of the data using CC_MD5.
CG_INLINE CGFloat NICGFloatSqRt(CGFloat x)
sqrt()/sqrtf() sized for CGFloat
CGRect NIRectContract(CGRect rect, CGFloat dx, CGFloat dy)
Modifies only the right and bottom edges of a CGRect.
CG_INLINE CGFloat NICGFloatCopySign(CGFloat x, CGFloat y)
copysign()/copysignf() sized for CGFloat
CG_INLINE CGFloat NICGFloatPow(CGFloat x, CGFloat y)
pow()/powf() sized for CGFloat
CG_INLINE CGFloat NICGFloatCeil(CGFloat x)
ceil()/ceilf() sized for CGFloat
CG_INLINE CGFloat NICGFloatFloor(CGFloat x)
floor()/floorf() sized for CGFloat
NSString * NIMD5HashFromString(NSString *string)
Calculates an md5 hash of the string using CC_MD5.
BOOL NIIsStringWithWhitespaceAndNewlines(NSString *string)
Returns a Boolean value indicating whether the string is a NSString object that contains only whitesp...
CGRect NIRectExpand(CGRect rect, CGFloat dx, CGFloat dy)
Modifies only the right and bottom edges of a CGRect.
CGFloat boundf(CGFloat value, CGFloat min, CGFloat max)
Deprecated method.
NSInteger boundi(NSInteger value, NSInteger min, NSInteger max)
Deprecated method.
NSString * NISHA1HashFromData(NSData *data)
Calculates a sha1 hash of the data using CC_SHA1.
CG_INLINE CGFloat NICGFloatCos(CGFloat x)
cos()/cosf() sized for CGFloat
NSString * NISHA1HashFromString(NSString *string)
Calculates a sha1 hash of the string using CC_SHA1.
CGSize NISizeOfStringWithLabelProperties(NSString *string, CGSize constrainedToSize, UIFont *font, NSLineBreakMode lineBreakMode, NSInteger numberOfLines)
Returns the size of the string with given UILabel properties.
CGFloat NIBoundf(CGFloat value, CGFloat min, CGFloat max)
Bounds a given value within the min and max values.
NSInteger NIBoundi(NSInteger value, NSInteger min, NSInteger max)
Bounds a given value within the min and max values.
NSComparisonResult NICompareVersionStrings(NSString *string1, NSString *string2)
Compares two strings expressing software versions.
CGRect NIRectShift(CGRect rect, CGFloat dx, CGFloat dy)
Modifies only the top and left edges of a CGRect.
NSInvocation * NIInvocationWithClassTarget(Class targetClass, SEL selector)
Construct an NSInvocation for a class method given a class object and a selector. ...
CG_INLINE CGFloat NICGFloatAbs(CGFloat x)
fabs()/fabsf() sized for CGFloat
CGFloat NICenterX(CGSize containerSize, CGSize size)
Returns the x position that will center size within containerSize.
CGFloat NICenterY(CGSize containerSize, CGSize size)
Returns the y position that will center size within containerSize.
NSString * NIStringByAddingQueryDictionaryToString(NSString *string, NSDictionary *query)
Appends a dictionary of query parameters to a string, adding the ? character if necessary.
NSInvocation * NIInvocationWithInstanceTarget(NSObject *target, SEL selector)
Construct an NSInvocation with an instance of an object and a selector.
CGRect NIFrameOfCenteredViewWithinView(UIView *viewToCenter, UIView *containerView)
Returns a rect that will center viewToCenter within containerView.
CG_INLINE CGFloat NICGFloatRound(CGFloat x)
round()/roundf() sized for CGFloat
NSString * NIStringByAddingPercentEscapesForURLParameterString(NSString *parameter)
Returns a string that has been escaped for use as a URL parameter.
CGRect NIEdgeInsetsOutsetRect(CGRect rect, UIEdgeInsets outsets)
Inverse of UIEdgeInsetsInsetRect.