Skip to content

Commit

Permalink
use set_ivar in dealloc
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Schott committed Jul 6, 2021
1 parent 94d7092 commit b6d2f15
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions rubicon/objc/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,7 @@ def _new_delloc(objc_self, _cmd):
# Clean up ivar.
if self.weak:
# Clean up weak reference.
ivar = libobjc.class_getInstanceVariable(libobjc.object_getClass(objc_self), ivar_name.encode())
libobjc.objc_storeWeak(objc_self.value + libobjc.ivar_getOffset(ivar), None)
set_ivar(objc_self, ivar_name, self.vartype(None), weak=True)
elif issubclass(self.vartype, objc_id):
# If the old value is a non-null object, release it. There is no need to set the actual ivar to nil.
old_value = get_ivar(objc_self, ivar_name, weak=self.weak)
Expand Down

0 comments on commit b6d2f15

Please sign in to comment.