Change vector index from operator [] to at() to avoid errors

Not solved the "object modified after being freed" error though.
Modified Xcode project for debugging