title: Registering setup code in objective-c
body: <p>Is there a standard mechanism with Objective C and the iOS runtime to register setup code?</p>
  <h1>Why?</h1>
  <p>The advantage of this is that you can decouple your code nicely.</p>
  <ul>
  <li><p>If a subsystem needs particular setup, the set up stays in that subsystem.</p>
  </li>
  <li><p>If a group of files need to register that they should all be offered as a particular service, that can be encapsulated in individual files that offer the service and there is no need for a separate configuration file to be kept up to date.</p>
  </li>
  </ul>
  <p>Getting the code to run isn't especially important  – I can do that myself with various entry points. What I need is for the compiler or linker or run time or <em>magic</em> to be able to collect up anything that I've registered in different parts of a program, and let me have it when I need it.</p>
  <h1>How to in c++</h1>
  <p>With c++, I've typically arranged for this with static instances that are constructed before main() is called. I could use objective-c++, but I'd much prefer to use a standard mechanism.</p>
  <p>Thanks.</p>