Anonymous avatar Anonymous committed 9871c83

Added Accessor() for creating signatures for KVC compliant method.

Comments (0)

Files changed (1)

pyobjc/Lib/objc/__init__.py

     """
     return selector(func, signature="v@:@")
 
+def Accessor(func):
+    """
+    Return an Objective-C method object that is conformant with key-value coding
+    and key-value observing.
+    """
+    argCount = func.func_code.co_argcount
+    if argCount is 2:
+        return selector(func, signature="v@:@")
+    elif argCount is 1:
+        return selector(func, signature="@@:")
+    elif argCount is 0:
+        raise ValueError, "Too few arguments to function '%s'.  Cannot create selector." % foo.func_name
+    else:
+        raise ValueError, "Too many arguments to function '%s'.  Cannot create selector." % foo.func_name
+
 def pluginBundle(pluginName):
     """
     Return the main bundle for the named plugin. This should be used
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.