(self, name, value)
Allows modifying Objective-C properties using Python syntax.

        If ``self`` has a Python attribute with the given name, it is set. Otherwise, the name should refer
        to an Objective-C property, whose setter method is called with ``value``.
Allows modifying Objective-C properties using Python syntax.
Allows modifying Objective - C properties using Python syntax .
def __setattr__(self, name, value):
        """Allows modifying Objective-C properties using Python syntax.

        If ``self`` has a Python attribute with the given name, it is set. Otherwise, the name should refer
        to an Objective-C property, whose setter method is called with ``value``.
        """

        if name in self.__dict__:
            # For attributes already in __dict__, use the default __setattr__.
            super(ObjCInstance, type(self)).__setattr__(self, name, value)
        else:
            method = self.objc_class._cache_property_mutator(name)
            if method:
                # Convert enums to their underlying values.
                if isinstance(value, enum.Enum):
                    value = value.value
                ObjCBoundMethod(method, self)(value)
            else:

                # Wrap the Python object in a WrappedPyObject instance.
                # A reference will be retained as long as the WrappedPyObject is alive.

                wrapper = send_message(
                    send_message(get_class('WrappedPyObject'), 'alloc',
                                 restype=objc_id, argtypes=[]),
                    'initWithObjectId:', id(value), restype=objc_id, argtypes=[objc_id]
                )

                # Set the Python value as an associated object. This will release
                # any previous wrapper object with the same key.
                key = self._associated_attr_key_for_name(name)
                libobjc.objc_setAssociatedObject(self, key, wrapper, 0x301)

                # Release the wrapper object, it will be retained by the association.
                send_message(wrapper, 'release', restype=objc_id, argtypes=[])
def __setattr__ ( self , name , value ) : if name in self . __dict__ : # For attributes already in __dict__, use the default __setattr__. super ( ObjCInstance , type ( self ) ) . __setattr__ ( self , name , value ) else : method = self . objc_class . _cache_property_mutator ( name ) if method : # Convert enums to their underlying values. if isinstance ( value , enum . Enum ) : value = value . value ObjCBoundMethod ( method , self ) ( value ) else : # Wrap the Python object in a WrappedPyObject instance. # A reference will be retained as long as the WrappedPyObject is alive. wrapper = send_message ( send_message ( get_class ( 'WrappedPyObject' ) , 'alloc' , restype = objc_id , argtypes = [ ] ) , 'initWithObjectId:' , id ( value ) , restype = objc_id , argtypes = [ objc_id ] ) # Set the Python value as an associated object. This will release # any previous wrapper object with the same key. key = self . _associated_attr_key_for_name ( name ) libobjc . objc_setAssociatedObject ( self , key , wrapper , 0x301 ) # Release the wrapper object, it will be retained by the association. send_message ( wrapper , 'release' , restype = objc_id , argtypes = [ ] )