Grand Central Dispatch Singletons

So… what’s the recommended way (thread safety + performance) to implement a singleton?

Well.. it looks pretty much like this!
[cc lang=”objc”]
+ (instancetype)sharedInstance
static dispatch_once_t pred;
static Foo* bar = nil;

dispatch_once(&pred, ^{ bar = [[Foo alloc] init]; });
return bar;

OSX Terminal: Adding current folder to the title!

If you’re just like me, and have lots of Terminal tabs open, you probably end up typing ‘pwd’ all the time.

Luckily, there is an easy solution:

  1. Create a file named ‘.profile’, in your user’s home.
  2. Type the following string in there!:
    [cc lang=”bash”]export PROMPT_COMMAND=’echo -ne “\033]0;[${PWD/$HOME/~}]\007″‘[/cc]

That’s it!. You’re gonna have, from now on, the current working directory right there in the windows tab!.


%d bloggers like this: