CYHelper 是一个为 iOS 开发者提供的 Objective-C 库。它试图提供 iOS 的所有有用特性,并将它们封装成易于使用的 API。
@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, readwrite) CGFloat x;
@property (nonatomic, readwrite) CGFloat y;
@property (nonatomic, readwrite) CGFloat width;
@property (nonatomic, readwrite) CGFloat height;
@property (nonatomic, readwrite) CGSize size;
@property (nonatomic, readwrite) CGPoint origin;
@property (nonatomic, readwrite) CGFloat bottom;
@property (nonatomic, readwrite) CGFloat right;
- (void)removeAllSubviews;
- (NSArray *)subarrayFromIndex:(NSUInteger)index;
- (NSArray *)subarrayToIndex:(NSUInteger)index;
// example: dateFormat:@"yyyy-MM-dd 'at' HH:mm";
// formattedDateString: 2001-01-02 at 13:00
- (NSString *)stringWithDateFormat:(NSString *)dateFormat;
- (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;
我参考了以下代码。感谢他们激发了我的灵感。感谢他们为开源社区做出的贡献。
CYHelper可在MIT许可证下使用。
版权所有©2012 Lancy。
在此特此免费授权,任何人获得此软件及其相关文档的副本(以下简称“软件”),均可以在不受限制的情况下处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本案例,并允许软件的接收者从事上述活动,前提是
上述版权声明和本许可声明应包含在软件的所有副本或实质性部分中。
软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、适用于特定目的和不侵犯知识产权的保证。在任何情况下,作者或版权所有者不应对任何索赔、损害或其他责任负责,无论是由合同、侵权或操作引起的,无论是在软件或软件的使用或任何其他联系中发生的。