title: How to create a Cocoa library and use it in python
body: <p>I've been making a game and the python library I was used is terrible (Pyglet). I want to try using Cocoa for the OSX version.</p>
  
  <p>I'll be able to figure out using the objects from classes like NSWindow and NSOpenGLView and then put these objects in my own class for the game loop.</p>
  
  <p>I have no idea how I can use PyObjC to load a dynamic Objective-C library I can make and then use the class I will make in python to setup the game which I suppose can be looped by NSTimer.</p>
  
  <p>However, the loop method will also need to call a python method from one of many python classes. My game consists of many python classes which are used for different sections of the game (Mapmaker,GameSession,AnacondaGame etc.). The game loop will need to call a loop method in any of these classes depending on the current section and pass even information.</p>
  
  <p>PyObjC is "bi-directional" apparently so how is that done?</p>
  
  <p>Alternatively I could create two methods to be called by python and I add the python code in-between, where the loop is controlled by python.</p>
  
  <p>The "documentation" on the PyObjC website only seem to explain how to use Cocoa in python and nothing else.</p>
  
  <p>What I can't do is make a fixed GUI with the interface builder because the library will need to create windows based on the python input to an initialisation method of my class.</p>
  
  <p>Knowing the syntax of Objective-C isn't a big problem and I can reefer to the Cocoa documentation to make the objects I require. </p>
  
  <p>Thank you for any help. It will be appreciated very much. I'm sick of using broken libraries like pygame and pyglet, using the platform specific OS APIs seems to be the best method to ensure quality.</p>