Xcode: notes

To reset Xcode to the default settings:

$ defaults delete com.apple.Xcode
$ rm -rf ~/Library/Application Support/Xcode

First, I dislike having a lot of popup windows so I set the layout to “All-In-One” to keep most things within a single window:


And my usual indentation style:


I like having the files autosaved on build:


sqlite3 rocks

I’d been using the sqlite3 that came installed on Mac OS X but I ran into some portability issues — not every system has it installed. So I decided to bite the bullet and include it with my code.
It was trivial! I downloaded a zip with 3 files (sqlite3.c,sqlite3.h, and sqlite3ext.h). Added sqlite3.c to my list of sources and it just compiled! No configuration, no trickly flags, it just worked!

Functor for deleting objects

In a destructor for a class, I had a std::vector of pointers that I wanted to delete. I started to write the usual for(;;) loop and realized I do this often enough I should make it easy to use std::for_each().
Here’s the functor (based on std::unary_function):

struct deleter: public std::unary_function
    bool operator()(Type * ptr) const
        delete ptr;
        return true;

And here’s some sample code using it:

std::vector m_symbols;
// ...
std::for_each (m_symbols.begin(), m_symbols.end(), deleter());

I added a return of true because some other template code wasn’t happy about “return void” — supposedly something fixed in recent compilers.