Permalink
Browse files

Even more debug code for _scrollViewDidChangeBounds

Since SPTableView and SPCopyTable seem to be the cause behind the majority of crashes let's take a closer look at them.
  • Loading branch information...
dmoagx committed Sep 14, 2015
1 parent 4707c32 commit aa192cfe24c2866554d8785152e045f42233f287
Showing with 47 additions and 1 deletion.
  1. +42 −1 Source/SPObjectAdditions.m
  2. +5 −0 Source/SPTableView.m
View
@@ -30,6 +30,7 @@
#import <objc/runtime.h>
static NSMutableDictionary *gScrollViewListeners;
static NSMutableDictionary *gScrollViewDealloc;
@implementation NSObject (SPObjectAdditions)
@@ -97,7 +98,10 @@ - (void)_scrollViewDidChangeBounds:(id)obj
NSString *key = [NSString stringWithFormat:@"snd=%p,obs=%p",obj,self];
[msg appendFormat:@"registration info for pair (%@):\n %@",key,[gScrollViewListeners objectForKey:key]];
[msg appendFormat:@"registration info for pair (%@):\n %@\n\n",key,[gScrollViewListeners objectForKey:key]];
NSString *deallocKey = [NSString stringWithFormat:@"=%p",self];
[msg appendFormat:@"self %@ was originally dealloc'ed at:\n %@",deallocKey,[gScrollViewDealloc objectForKey:deallocKey]];
@throw [NSException exceptionWithName:NSInternalInconsistencyException reason:msg userInfo:nil];
}
@@ -144,4 +148,41 @@ - (void)sp_addObserver:(id)notificationObserver selector:(SEL)notificationSelect
[self sp_addObserver:notificationObserver selector:notificationSelector name:notificationName object:notificationSender];
}
@end
#import "SPTableView.h"
@implementation SPTableView (SPScrollViewDebug)
+ (void)load
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
gScrollViewDealloc = [[NSMutableDictionary alloc] init];
Class tableView = [self class];
SEL orig = @selector(dealloc);
SEL exch = @selector(sp_dealloc);
Method origM = class_getInstanceMethod(tableView, orig);
Method exchM = class_getInstanceMethod(tableView, exch);
method_exchangeImplementations(origM, exchM);
});
}
- (void)sp_dealloc
{
NSString *key = [NSString stringWithFormat:@"=%p",self];
NSString *val = [NSString stringWithFormat:@"\ndealloc backtrace:\n%@\n\n",[NSThread callStackSymbols]];
[gScrollViewDealloc setObject:val forKey:key];
// not recursive! method is swizzled.
[self sp_dealloc];
}
@end
View
@@ -61,6 +61,11 @@ - (id) init
return self;
}
- (void)dealloc
{
[super dealloc];
}
- (void) awakeFromNib
{
[super setDoubleAction:@selector(_doubleClickAction)];

0 comments on commit aa192cf

Please sign in to comment.