Category Archives: other

docker completion for zprezto

ln -s /Applications/Docker.app/Contents/Resources/etc/docker.zsh-completion /usr/local/share/zsh/site-functions/_docker
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-machine.zsh-completion /usr/local/share/zsh/site-functions/_docker-machine
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.zsh-completion /usr/local/share/zsh/site-functions/_docker-compose

Singletons in Objective-C

ShareObject.h

#import 

@interface ShareObject : NSObject {
    NSString *someVariable;
}

@property (nonatomic, retain) NSString *someVariable;

+ (id)sharedManager;

@end

ShareObject.m

#import "ShareObject.h"

@implementation ShareObject

@synthesize someVariable;

+ (id)sharedManager {
    static ShareObject *shareObject = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        shareObject = [[self alloc] init];
    });
    return shareObject;
}

- (id)init {
    if (self = [super init]) {
        someVariable = @"some value";
    }
    return self;
}

- (void)dealloc {
    // Should never be called, but just here for clarity really.
}

@end

How to use

ShareObject *shareObject = [ShareObject sharedManager];