(func, typeSignature=b'@')
Return an Objective-C method object that is conformant with key-value coding
    and key-value observing.
Return an Objective-C method object that is conformant with key-value coding
    and key-value observing.
Return an Objective - C method object that is conformant with key - value coding and key - value observing .
def accessor(func, typeSignature=b'@'):
    """
    Return an Objective-C method object that is conformant with key-value coding
    and key-value observing.
    """
    if getfullargspec is not None:
        args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations = getfullargspec(func)
    else:
        args, varargs, varkw, defaults = getargspec(func)
        kwonlyargs = kwonlydefaults = annotations = None
    funcName = func.__name__
    maxArgs = len(args)
    minArgs = maxArgs - len(defaults or ())
    # implicit self
    selArgs = 1 + funcName.count('_')
    if varargs is not None or varkw is not None or kwonlyargs:
        raise TypeError('%s can not be an accessor because it accepts varargs, varkw or kwonly' % (funcName,))

    if not (minArgs <= selArgs <= maxArgs):
        if minArgs == maxArgs:
            raise TypeError('%s expected to take %d args, but must accept %d from Objective-C (implicit self plus count of underscores)' % (funcName, maxArgs, selArgs))
        else:
            raise TypeError('%s expected to take between %d and %d args, but must accept %d from Objective-C (implicit self plus count of underscores)' % (funcName, minArgs, maxArgs, selArgs))

    if selArgs == 3:
        if funcName.startswith('validate') and funcName.endswith('_error_'):
            return selector(func, signature=_C_NSBOOL + b'@:N^@o^@')

        if funcName.startswith('insertObject_in') and funcName.endswith('AtIndex_'):
            return selector(func, signature=b'v@:' + typeSignature + _C_NSUInteger)
        elif funcName.startswith('replaceObjectIn') and funcName.endswith('AtIndex_withObject_'):
            return selector(func, signature=b'v@:' + _C_NSUInteger + typeSignature)

        elif funcName.startswith('get') and funcName.endswith('_range_'):
            return selector(func, signature=b'v@:o^@' + _C_NSRange)

        elif funcName.startswith('insert') and funcName.endswith('_atIndexes_'):
            return selector(func, signature=b'v@:@@')

        elif funcName.startswith('replace') and 'AtIndexes_with' in funcName:
            return selector(func, signature=b'v@:@@')

        # pass through to "too many arguments"

    elif selArgs == 2:
        if funcName.startswith('objectIn') and funcName.endswith('AtIndex_'):
            return selector(func, signature=typeSignature + b'@:' + _C_NSUInteger)
        elif funcName.startswith('removeObjectFrom') and funcName.endswith('AtIndex_'):
            return selector(func, signature=b'v@:' + _C_NSUInteger)
        elif funcName.startswith('remove') and funcName.endswith('AtIndexes_'):
            return selector(func, signature=b"v@:@")
        elif funcName.endswith('AtIndexes_'):
            return selector(func, signature=b"@@:@")
        elif funcName.startswith('memberOf'):
            return selector(func, signature=_C_NSBOOL + b"@:" + typeSignature)
        elif funcName.startswith('add') and funcName.endswith('Object_'):
            return selector(func, signature=b"v@:" + typeSignature)
        elif funcName.startswith('add'):
            return selector(func, signature=b"v@:@")
        elif funcName.startswith('intersect'):
            return selector(func, signature=b"v@:@")

        return selector(func, signature=b"v@:" + typeSignature)

    elif selArgs == 1:
        if funcName.startswith('countOf'):
            typeSignature = _C_NSUInteger
        elif funcName.startswith('enumerator'):
            typeSignature = b"@"


        return selector(func, signature=typeSignature + b"@:")

    raise TypeError("%s not recognized as an accessor" % (funcName,))
def accessor ( func , typeSignature = b'@' ) : if getfullargspec is not None : args , varargs , varkw , defaults , kwonlyargs , kwonlydefaults , annotations = getfullargspec ( func ) else : args , varargs , varkw , defaults = getargspec ( func ) kwonlyargs = kwonlydefaults = annotations = None funcName = func . __name__ maxArgs = len ( args ) minArgs = maxArgs - len ( defaults or ( ) ) # implicit self selArgs = 1 + funcName . count ( '_' ) if varargs is not None or varkw is not None or kwonlyargs : raise TypeError ( '%s can not be an accessor because it accepts varargs, varkw or kwonly' % ( funcName , ) ) if not ( minArgs <= selArgs <= maxArgs ) : if minArgs == maxArgs : raise TypeError ( '%s expected to take %d args, but must accept %d from Objective-C (implicit self plus count of underscores)' % ( funcName , maxArgs , selArgs ) ) else : raise TypeError ( '%s expected to take between %d and %d args, but must accept %d from Objective-C (implicit self plus count of underscores)' % ( funcName , minArgs , maxArgs , selArgs ) ) if selArgs == 3 : if funcName . startswith ( 'validate' ) and funcName . endswith ( '_error_' ) : return selector ( func , signature = _C_NSBOOL + b'@:N^@o^@' ) if funcName . startswith ( 'insertObject_in' ) and funcName . endswith ( 'AtIndex_' ) : return selector ( func , signature = b'v@:' + typeSignature + _C_NSUInteger ) elif funcName . startswith ( 'replaceObjectIn' ) and funcName . endswith ( 'AtIndex_withObject_' ) : return selector ( func , signature = b'v@:' + _C_NSUInteger + typeSignature ) elif funcName . startswith ( 'get' ) and funcName . endswith ( '_range_' ) : return selector ( func , signature = b'v@:o^@' + _C_NSRange ) elif funcName . startswith ( 'insert' ) and funcName . endswith ( '_atIndexes_' ) : return selector ( func , signature = b'v@:@@' ) elif funcName . startswith ( 'replace' ) and 'AtIndexes_with' in funcName : return selector ( func , signature = b'v@:@@' ) # pass through to "too many arguments" elif selArgs == 2 : if funcName . startswith ( 'objectIn' ) and funcName . endswith ( 'AtIndex_' ) : return selector ( func , signature = typeSignature + b'@:' + _C_NSUInteger ) elif funcName . startswith ( 'removeObjectFrom' ) and funcName . endswith ( 'AtIndex_' ) : return selector ( func , signature = b'v@:' + _C_NSUInteger ) elif funcName . startswith ( 'remove' ) and funcName . endswith ( 'AtIndexes_' ) : return selector ( func , signature = b"v@:@" ) elif funcName . endswith ( 'AtIndexes_' ) : return selector ( func , signature = b"@@:@" ) elif funcName . startswith ( 'memberOf' ) : return selector ( func , signature = _C_NSBOOL + b"@:" + typeSignature ) elif funcName . startswith ( 'add' ) and funcName . endswith ( 'Object_' ) : return selector ( func , signature = b"v@:" + typeSignature ) elif funcName . startswith ( 'add' ) : return selector ( func , signature = b"v@:@" ) elif funcName . startswith ( 'intersect' ) : return selector ( func , signature = b"v@:@" ) return selector ( func , signature = b"v@:" + typeSignature ) elif selArgs == 1 : if funcName . startswith ( 'countOf' ) : typeSignature = _C_NSUInteger elif funcName . startswith ( 'enumerator' ) : typeSignature = b"@" return selector ( func , signature = typeSignature + b"@:" ) raise TypeError ( "%s not recognized as an accessor" % ( funcName , ) )