Soo
Soo

Reputation: 397

ios crash issue - EXC_BAD_ACCESS

I got this error message from Crashlytics.

Exception Type: EXC_BAD_ACCESS Code: KERN_INVALID_ADDRESS at 0xd000000c

Thread 0: Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x3b283b26 objc_msgSend + 5
1  TestApp                       0x0012b239 -[EasyTableView scrollViewDidScroll:]      (EasyTableView.m:291)
2  UIKit                          0x339f006d -[UIScrollView(UIScrollViewInternal) _notifyDidScroll] + 64
3  UIKit                          0x3376d375 -[UIScrollView setContentOffset:] + 596
4  UIKit                          0x3381b005 -[UITableView setContentOffset:] + 320
5  UIKit                          0x3376d0e7 -[UIScrollView _adjustContentOffsetIfNecessary] + 1354
6  UIKit                          0x33820773 -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:tramplingDragFlags:] + 414
7  UIKit                          0x338205cb -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:] + 30
8  UIKit                          0x33820587 -[UIScrollView removeFromSuperview] + 30
9  UIKit                          0x3374e687 -[UIView dealloc] + 366
10 liboainject.dylib              0x002d86cd ___swapMethods_block_invoke_4
11 UIKit                          0x3374e687 -[UIView dealloc] + 366
12 liboainject.dylib              0x002d86cd ___swapMethods_block_invoke_4
13 UIKit                          0x3374e687 -[UIView dealloc] + 366
14 liboainject.dylib              0x002d86cd ___swapMethods_block_invoke_4
15 libobjc.A.dylib                0x3b285007 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 358
16 liboainject.dylib              0x002d7d33 __oa__objc_autoreleasePoolPop
17 CoreFoundation                 0x30f10a41 _CFAutoreleasePoolPop + 16
18 UIKit                          0x337464cd _wrapRunLoopWithAutoreleasePoolHandler + 36
19 CoreFoundation                 0x30fa81d5 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
20 CoreFoundation                 0x30fa5b79 __CFRunLoopDoObservers + 284
21 CoreFoundation                 0x30fa5ebb __CFRunLoopRun + 730
22 CoreFoundation                 0x30f10ce7 CFRunLoopRunSpecific + 522
23 CoreFoundation                 0x30f10acb CFRunLoopRunInMode + 106
24 GraphicsServices               0x35bfa283 GSEventRunModal + 138
25 UIKit                          0x337b2a41 UIApplicationMain + 1136
26 TestApp                       0x000ea19d main (main.m:16)

My code (EasyTableView.m: 291) is as below

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if ([delegate respondsToSelector:@selector(easyTableView:scrolledToOffset:)])
        [delegate easyTableView:self scrolledToOffset:self.contentOffset];
}

- (CGPoint)contentOffset {
    CGPoint offset = self.tableView.contentOffset;

    if (_orientation == EasyTableViewOrientationHorizontal)
        offset = CGPointMake(offset.y, offset.x);

    return offset;
}


- (void)setContentOffset:(CGPoint)offset {
    if (_orientation == EasyTableViewOrientationHorizontal)
        self.tableView.contentOffset = CGPointMake(offset.y, offset.x);
    else
        self.tableView.contentOffset = offset;
}

I tried to debug with Zombie and looked into Leaks of instrument. But I could not found any thing. How can I fix this problem? Thanks in advance

Upvotes: 2

Views: 3971

Answers (2)

jfgrang
jfgrang

Reputation: 1178

In Swift :

deinit {
   self.scrollView.delegate = nil
   self.tableView.delegate = nil
}

Upvotes: -1

dwery
dwery

Reputation: 1116

You should clear the scrollView and tableView delegates in dealloc

Upvotes: 12

Related Questions