#CYHelper
This project is not longer maintained.
CYHelper is an Objective-C library for iOS developer. It try to provides all the useful features of iOS and wrap them to be easy-to-use API.
###1.1.5
- UIDevice category for platform infomation.
See More at ChangeLog.md
- UIDevice category for platform infomation.
- NSArray and NSSet utils: map, filter and reject with block, flattenArray.
- Days with in era from date to date.
- Easy to associcated objects.
- Attach userinfo to UIAlertView, UIActionSheet, UIControl
- Easy to post and observe notification to default notification center.
- Easy to access subarray
- Convert date to string with date format
- JSON Serialization with NSData, NSString, NSDictionary
- MD5 generation with NSData, NSString
- Word Tokenization with string.
- Singleton(sharedInstance Method) macro
- Runtime print call stack
- Check OS version, app version, device model
- Check whether device is jail broken
- Perform block after delay
- Create UIColor With RGBHex
- Easy to access x, y, centerY, centerX, width, height, right, bottom, origin and size of UIView.
- Determind is iPhone or iPad
- Remove all subviews of view
- NSNumber simple calculation.
- iOS 5.0 or later
- support ARC
- Use CocoaPods to install CYHelper.
- Or simply drag CYHelper folder to your project, and import "CYHelper.h". Otherwise you can also add individual componet of CYHelper, just import corresponding head files.
- (NSString *)platform;
- (CYPlatformType)platformType;
- (NSString *)platformString;
@property (strong, nonatomic) NSDictionary *userInfo;
@property (strong, nonatomic) NSDictionary *userInfo;
@property (strong, nonatomic) NSDictionary *userInfo;
- (void)associateValue:(id)value withKey:(const void *)key;
- (void)atomicallyAssociateValue:(id)value withKey:(const void *)key;
- (void)associateCopyOfValue:(id)value withKey:(const void *)key;
- (void)atomicallyAssociateCopyOfValue:(id)value withKey:(const void *)key;
- (void)weaklyAssociateValue:(id)value withKey:(const void *)key;
- (id)associatedValueForKey:(const void *)key;
- (void)removeAllAssociatedObjects;
+ (void)associateValue:(id)value withKey:(const void *)key;
+ (void)atomicallyAssociateValue:(id)value withKey:(const void *)key;
+ (void)associateCopyOfValue:(id)value withKey:(const void *)key;
+ (void)atomicallyAssociateCopyOfValue:(id)value withKey:(const void *)key;
+ (void)weaklyAssociateValue:(id)value withKey:(const void *)key;
+ (id)associatedValueForKey:(const void *)key;
+ (void)removeAllAssociatedObjects;
// DO NOT USE THEM when you have perfomace problem.
// These method convert NSNumber to NSDecimalNumber to process the calculation.
// I provide these methods just for convenience.
// NSDecimal(C-level) is much faster than NSDecimalNumber, can be a better choice.
- (NSNumber *)addNumber:(NSNumber *)number;
- (NSNumber *)subNumber:(NSNumber *)number;
- (NSNumber *)mulNumber:(NSNumber *)number;
- (NSNumber *)divNumber:(NSNumber *)number;
- (NSNumber *)modNumber:(NSNumber *)number;
- (void)postNotificationName:(NSString *)notificationName;
- (void)postNotificationName:(NSString *)notificationName userInfo:(NSDictionary *)userInfo;
- (void)observeNotificationName:(NSString *)notificationName selector:(SEL)selector;
- (void)unObserveNotificationName:(NSString *)notificationName;
- (void)performBlock:(void (^)(void))block afterDelay:(NSTimeInterval)delay;
+ (UIColor *)colorWithRGBHex:(UInt32)hex;
+ (UIColor *)colorWithRGBHex:(UInt32)hex alpha:(CGFloat)alpha;
@property (nonatomic) CGFloat x;
@property (nonatomic) CGFloat y;
@property (nonatomic) CGFloat width;
@property (nonatomic) CGFloat height;
@property (nonatomic) CGSize size;
@property (nonatomic) CGPoint origin;
@property (nonatomic) CGFloat bottom;
@property (nonatomic) CGFloat right;
@property (nonatomic) CGFloat centerX;
@property (nonatomic) CGFloat centerY;
- (void)removeAllSubviews;
- (NSArray *)subarrayFromIndex:(NSUInteger)index;
- (NSArray *)subarrayToIndex:(NSUInteger)index;
- (NSArray *)map:(id (^)(id value))handlerBlock;
- (NSArray *)filter:(BOOL (^)(id value))handlerBlock;
- (NSArray *)reject:(BOOL (^)(id value))handlerBlock;
- (NSArray *)flattenArray;
- (NSSet *)map:(id (^)(id value))handlerBlock;
- (NSSet *)filter:(BOOL (^)(id value))handlerBlock;
- (NSSet *)reject:(BOOL (^)(id value))handlerBlock;
// example: dateFormat:@"yyyy-MM-dd 'at' HH:mm";
// formattedDateString: 2001-01-02 at 13:00
- (NSString *)stringWithDateFormat:(NSString *)dateFormat;
- (NSInteger)daysWithinEraToDate:(NSDate *)toDate;
- (NSData *)jsonData;
- (NSString *)jsonString;
- (NSData *)MD5;
- (NSString *)MD5String;
- (NSDictionary *)jsonObject;
- (NSDictionary *)jsonObject;
- (NSString *)MD5String;
- (NSArray *)arrayWithWordTokenize;
- (NSString *)separatedStringWithSeparator:(NSString *)separator;
#define IOS7_OR_LATER
#define IOS6_OR_LATER
#define IOS5_OR_LATER
#define IOS4_OR_LATER
#define IOS3_OR_LATER
#define IS_IPHONE
#define IS_IPAD
+ (NSString *)osVersion;
+ (NSString *)appVersion;
+ (NSString *)deviceModel;
+ (BOOL)isJailBroken;
+ (NSString *)jailBreaker;
#define AS_SINGLETON( __class )
#define DEF_SINGLETON( __class )
+ (void)printCallStackWithCount:(NSUInteger)count;
- Follow my github
- Write an issue
- Send Email to me: lancy1014@gmail.com
I refer to the following code. Thank them sparked my inspiration. Thank them for their contributions to the open source community.
CYHelper is available under the WTFPL license.
Copyright © 2012-2014 Lancy.