Closed armadsen closed 5 years ago
Despite the use of +[NSValue valueWithNonretainedObject:], ports are retained by allSerialPorts here:
+[NSValue valueWithNonretainedObject:]
allSerialPorts
+ (void)addSerialPort:(ORSSerialPort *)port; { [allSerialPorts addObject:[NSValue valueWithNonretainedObject:port]]; } + (void)removeSerialPort:(ORSSerialPort *)port; { NSValue *valueToRemove = nil; for (NSValue *value in allSerialPorts) { if ([value nonretainedObjectValue] == port) { valueToRemove = value; break; } } if (valueToRemove) [allSerialPorts removeObject:valueToRemove]; }
This could be fixed by using NSPointerArray instead.
NSPointerArray
I'm cautious about changing this, though, because it's likely to break code that is inadvertently relying on this behavior.
Nevermind, this isn't actually true. It was only the retain cycles (see #139) keeping the port alive.
Despite the use of
+[NSValue valueWithNonretainedObject:]
, ports are retained byallSerialPorts
here:This could be fixed by using
NSPointerArray
instead.I'm cautious about changing this, though, because it's likely to break code that is inadvertently relying on this behavior.