AtSugar 0.1.1

AtSugar 0.1.1

TestsTested
LangLanguage Obj-CObjective C
License Custom
ReleasedLast Release Sep 2015

Maintained by Dustin Bachrach.



AtSugar 0.1.1

  • By
  • Dustin Bachrach

AtSugar gives a little syntax sugar to your @ sign.

For more background and a deeper dive into AtSugar, check out the introductory blog post.

Here's a whirlwind tour of what AtSugar adds:

#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

Dig into the header files to see what else AtSugar can do!

Installation

Author

MediaHound

License

AtSugar is available under the Apache License 2.0. See the LICENSE file for more info.