By @ErikRalston
@interface Singleton : NSObject+ (Singleton*)shared;@end
@implementation Settings+ (Singleton *)shared{static Singleton *instance = nil;if(!instance)instance = [[super allocWithZone:nil] init];return instance;}+ (id)allocWithZone:(NSZone *)zone{return [self shared];}@end
// Declaring block inline, every time
@property (nonatomic,assign) (void (^)(void)) voidBlockProperty;
// Declaring a block once
typedef void (^VoidBlock)();
// Clean declarations forevermore @property (nonatomic,assign) VoidBlock voidBlockProperty;
#ifndef Blocks_h#define Blocks_h#import <Foundation/Foundation.h>typedef void (^VoidBlock)();typedef BOOL (^ReturnBoolBlock)();typedef void (^DictionaryBlock)(NSDictionary *dictionary);typedef void (^TableCellIndexPathBlock)(UITableViewCell *cell,NSIndexPath *indexPath);#endif
NSOperationQueue* otherQueue = [[NSOperationQueue alloc] init];[queue addOperationWithBlock:^{// Do work off the main thread here}];NSOperationQueue* queue = [NSOperationQueue mainQueue];[queue addOperationWithBlock:^{// Do work back on the main thread here}];
+(NSString *)cachesDirectoryName{static NSString *cachePath = nil;if(!cachePath) {NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);cachePath = [paths objectAtIndex:0];}return cachePath;}
+(NSString *)pathForName:(NSString *)name{NSString *cachePath = [SimpleFilesCache cachesDirectoryName];NSString *path = [cachePath stringByAppendingPathComponent:name];return path;}+(void)saveToCacheDirectory:(NSData *)data withName:(NSString *)name{NSString *path = [SimpleFilesCache pathForName:name];[data writeToFile:path atomically:YES];}
+(NSData *)cachedDataWithName:(NSString *)name{NSString *path = [SimpleFilesCache pathForName:name];BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:path];if(fileExists) {NSData *data = [NSData dataWithContentsOfFile:path];return data;} else {return nil;}}
brew install appledoc
appledocs
--project-name Flex
--project-company Flex
--output ../appledocs/
.