I'm trying to implement an indexed accessor method for my model class in Python, as per the KVC guide. I want to use the optional ranged method, to load multiple objects at once for performance reasons. The method takes a pointer to a C-array buffer which my method needs to copy the objects into. I've tried something like the following, which doesn't work. How do I accomplish this?
@objc.accessor # i've also tried @objc.signature('v@:o^@')
def getFoos_range_(self, range):
return self._some_array[range.location:range.location + range.length]
Edit: I finally found the type encodings reference after Apple moved all the docs. After reading that, I tried this:
@objc.signature('v@:N^@@')
def getFoos_range_(self, buf, range):
but this didn't appear to work either. The first argument is supposed to be a pointer to a C-array, but the length is unknown until runtime, so I didn't know exactly how to construct the correct type encoding. I tried 'v@:N^[1000@]@'
just to see, and that didn't work either.
My model object is bound to the contentArray of an NSArrayController driving a table view. It doesn't appear to be calling this method at all, perhaps because it expects a different signature than the one the bridge is providing. Any suggestions?