Sugar for your @
Objective-C Ruby C C++
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Example
Pod/Classes
.gitignore
AtSugar.podspec
LICENSE
README.md

README.md

AtSugar

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

AtSugar is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "AtSugar"

Author

MediaHound

License

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