[Pythonmac-SIG] lists and accessors

Georg Seifert georg.seifert at gmx.de
Thu Jul 8 23:00:02 CEST 2010


Hi,

In my app I will access my cocoa data classes from a python script (run from within the app). This works fine, I can access all the methods and properties. For some of the array properties I use dedicated getter and setter (getItemAtIndex: , setItemAtIndex: ...).

I have a cocoa object:

@interface myObject : NSObject {
	NSMutableArray *_items;
}
@property(retain) NSArray * items;
- (void) setItem:(id) Item atIndex: (int) Index;
- (id) itemAtIndex: (int) Index;
@end

Is it possible to access like:
	object.items()[i]	# it would be even better to get rid of the parenthesis.
or
	object.items.append(NewItem)

Calling from python should call the cocoa accessors instead of accessing the list directly. (I need to set some values and implemented undo in the accessors.)

My users are used to plain python scripting environments and don’t like the cocoa method names.

Is it somehow possible to tell python what accessors to use or is there a way to supply python wrappers? Or could I build a bridgesupport file?

Many Thanks
Georg


More information about the Pythonmac-SIG mailing list