(name, copy=False, readwrite=True, type=_C_ID, ivarName=None)
Use this in a class dictionary to syntheze simple setting/setter methods.

    Note: this is only necessary to get propper behaviour when Key-Value coding
    is used and special features (like copying) are needed

    usage::

        class MyClass (NSObject):
            objc.synthesize('someTitle', copy=True)
Use this in a class dictionary to syntheze simple setting/setter methods.
Use this in a class dictionary to syntheze simple setting / setter methods .
def synthesize(name, copy=False, readwrite=True, type=_C_ID, ivarName=None):
    """
    Use this in a class dictionary to syntheze simple setting/setter methods.

    Note: this is only necessary to get propper behaviour when Key-Value coding
    is used and special features (like copying) are needed

    usage::

        class MyClass (NSObject):
            objc.synthesize('someTitle', copy=True)

    """
    if not name:
        raise ValueError("Empty property name")

    if ivarName is None:
        ivarName = '_' + name

    classDict = sys._getframe(1).f_locals

    setterName = 'set%s%s_'%(name[0].upper(), name[1:])

    if copy:
        setter = textwrap.dedent('''
            def %(name)s(self, value):
                self.%(ivar)s = value.copy()
            ''' % dict(name=setterName, ivar=ivarName))

    else:
        setter = textwrap.dedent('''
            def %(name)s(self, value):
                self.%(ivar)s = value
            ''' % dict(name=setterName, ivar=ivarName))

    getter = textwrap.dedent('''
            def %(name)s(self):
                return self.%(ivar)s
            ''' % dict(name=name, ivar=ivarName))

    if readwrite:
        exec(setter, globals(), classDict)

    exec(getter, globals(), classDict)

    classDict[ivarName] = ivar(type=type)
def synthesize ( name , copy = False , readwrite = True , type = _C_ID , ivarName = None ) : if not name : raise ValueError ( "Empty property name" ) if ivarName is None : ivarName = '_' + name classDict = sys . _getframe ( 1 ) . f_locals setterName = 'set%s%s_' % ( name [ 0 ] . upper ( ) , name [ 1 : ] ) if copy : setter = textwrap . dedent ( '''
            def %(name)s(self, value):
                self.%(ivar)s = value.copy()
            ''' % dict ( name = setterName , ivar = ivarName ) ) else : setter = textwrap . dedent ( '''
            def %(name)s(self, value):
                self.%(ivar)s = value
            ''' % dict ( name = setterName , ivar = ivarName ) ) getter = textwrap . dedent ( '''
            def %(name)s(self):
                return self.%(ivar)s
            ''' % dict ( name = name , ivar = ivarName ) ) if readwrite : exec ( setter , globals ( ) , classDict ) exec ( getter , globals ( ) , classDict ) classDict [ ivarName ] = ivar ( type = type )