AtSugar 为您的 @
符号提供一点语法糖。
有关 AtSugar 的更多背景信息,请查看介绍博客文章。
以下是 AtSugar 增加的功能快速浏览
#import <AtSugar/AtSugar.h> // You can put this in your *.pch
//
// Grab a weak reference to `self`:
//
@weakSelf()
[self saveBlock:^{
[weakSelf go]; // `weakSelf` will be captured weakly
}];
//
// Easily implement the singleton pattern
//
@interface MyClass : NSObject
+ (instancetype)sharedInstance;
@end
@implementation MyClass
@singleton(sharedInstance)
@end
//
// Easily implement associated objects
//
#import <objc/runtime.h>
@interface UIImage (MyCategory)
@property (strong, nonatomic) NSString* myProperty;
@end
@implementation UIImage (MyCategory)
@associated_object (myProperty, setMyProperty)
@end
//
// Declarative class properties
//
@interface MyCell : UICollectionViewCell
+ (NSString*)xibName;
@end
@implementation MyCell
@declare_class_property (xibName, @"MyCell.xib")
@end
深入了解头文件,看看 AtSugar 还能做什么!
MediaHound
AtSugar 可在 Apache License 2.0 许可下使用。有关更多信息,请参阅 LICENSE 文件。