Ok here Is my version of Python-ObjC. For all you noobs, it is a bridge/wrapper written in python to access ObjectivE-C classes and objects. I used python-ctypes instead of writing it in C like PyObjC. I've been working on this the past couple weeks and It is perfected I believe. It comes with some example scripts that I modified, using another project called cocoapy. I copied absolutley no code from that project except for the example scripts because I did not know any ObjC at the time and am still learning. Even still they had to be modified to work with my module.
You can checkout with this command:
svn co https://ios-python-objc.googlecode.com/svn/trunk objcOk, one of the most important functions you will use are
load_library()I did not load UIKit or Foundation within the module itself, this will be something done within the user script. So to load say UIKit, its as easy as
load_library("UIKit")No path definition neccesarry as long as the frameworks are in the right path. Actually the libraryloader is very smart and shouldn't have trouble finding any dylibs or frameworks you throw in there.
Take for example list_classes.py
# List the names of all loaded Objective-C classes.
import objc
import ctypes
import sys
framework = sys.argv[1]
objc.load_library(framework)
count = objc.objc_getClassList(None, 0)
print '%d classes found:' % count
classes = (ctypes.c_void_p * count)()
count = objc.objc_getClassList(classes, count)
class_names = []
for cls in classes:
class_names.append(objc.class_getName(cls))
class_names.sort()
for name in class_names:
print name
This script will list all classes available from a given framework or library. It is used with
python list_classes.py UIKitfor example, "UIKit" being the example.
So far this module is pretty dependent on /usr/lib/libobjc.dylib and will not be functional without it. I hope to soon create a functional GUI app with this but who knows, thats why I released it so others could play with it.