Skip to content
Browse files

Hack for fixing ARC overrelease (sometimes)

  • Loading branch information...
1 parent 5adf2b7 commit 86124b3d8660ed7732bd6bb7ebfd4bec7f061fd5 Adam Milligan and Sam Coward committed
Showing with 6 additions and 0 deletions.
  1. +6 −0 Source/Doubles/CDRSpy.mm
View
6 Source/Doubles/CDRSpy.mm
@@ -12,7 +12,13 @@ + (void)interceptMessagesForInstance:(id)instance {
CedarDoubleImpl *cedar_double_impl = [[[CedarDoubleImpl alloc] initWithDouble:instance] autorelease];
objc_setAssociatedObject(instance, @"cedar-double-implementation", cedar_double_impl, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ NSUInteger originalRetainCount = [instance retainCount];
object_setClass(instance, self);
+ NSInteger shortfall = originalRetainCount - [instance retainCount];
+
+ while (shortfall-- > 0) {
+ [instance retain];
+ }
}
- (void)dealloc {

0 comments on commit 86124b3

Please sign in to comment.
Something went wrong with that request. Please try again.