title: python and objc bridge in an existing application
body: <p>I resently started programming in objc and I was wandering how can I use python code in an existing objc application. I found some threads in this site and some others but they didn't help me at all. What I want to do is to take the SpotlightAPI found in <a href="http://developer.apple.com/mac/library/samplecode/SpotlightAPI/Introduction/Intro.html" rel="nofollow noreferrer">apple's developer website</a> and use the results to process them with python code. Until now, I've done the following: <br /> 1. downloaded the SpotlightAPI from apple <br />2. created a new project based on the cocoa-python application template from PyObjc <br />3. added the controller files from the SpotlightAPI to the PyObjC <br />4. Configured the bindings the same way they where in the SpotlightAPI<br />5. Executed the program and all works successfully <br />6. created a new python class file which inherits from NSObject (called python.py)<br />7. the python file has the following code:<br /></p>
  
  <pre><code>from Foundation import *
  import objc
  
  NSObject = objc.lookUpClass(u"NSObject")
  print "PYTHON VERSION BEING USED:"
  
  class Python(NSObject):
      def sendit_(self, something):
          print something
          return "asdf"
  </code></pre>
  
  <p><br />
  8. I Inserted this code at the beginning of the Controller.m file:</p>
  
  <pre><code>@class Python;
  
  @interface NSObject (MethodsThatReallyDoExist)
  -(NSString *) sendit: (id) aString;
  
  @end
  
  @implementation Controller
  - (id)init
  {
      self = [super init];
      Class pythonClass = NSClassFromString(@"Python");
      myPython = [pythonClass new];
      NSLog(@"Created PythonClass: %@", myPython);
      NSString * oneString = [myPython sendit:@"asdf"];
      NSLog(@"%@", oneString);
      return self;
  }
  </code></pre>
  
  <p><br />
  9. added <code>id *myPython;</code> in the variable declarations in the Controller.h file
  <br />
  10. implemented the sendit method in the controller.m file like this:</p>
  
  <pre><code>- (NSString *) sendit:(id) aString
  {
  
      return [myPython sendit:aString];
  }
  </code></pre>
  
  <p><br />
  it compiles and runs successfully but the console message I'm getting from the init function is: <code>Created PythonClass: (null)</code> and also the string return of the next log is <code>(null)</code>
  <br />
  anyone knows what am I doing wrong?</p>