Search code examples
pythonobjective-cpyobjc

PyObjC call objective-c function with parameters (passed by value) in python


I'm trying to add my own Objective-C framework to a python project using pyobjc. The thing is, when I try and call functions with passed by value parameters (haven't tried by reference) it moans and gives me

"AttributeError: No attribute function_with_param".

Does anyone know why this error is happening? Bare bones code of what I'm doing in python is below. I'm probably being blind, but I haven't found anything on how to do this anywhere. If anyone can help it'd be awesome! :)

import objc

bundle = objc.loadBundle("OBJC", globals(),
    bundle_path=objc.pathForFramework('OSX/OBJC.framework'))

OBJC.function_with_param('a')
OBJC.function_without_param()

Ps. Sorry for the formatting in advance. Never done this before..!


Solution

  • Turns out I was missing an underscore, it works when you do this:

    OBJC.function_with_param_('a')
    

    Found it here: http://lists.stat.ucla.edu/pipermail/computing/attachments/20050825/f9a98389/attachment.pdf