Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS - EXC_BAD_ACCESS code = 1 UIWebView crashes after (method swizzling) init
    text
    copied!<p>I just switched my app over to ARC. The transition was a partial success thanks to the refactoring tool that Xcode provides. The one part that doesn't work is a strange error. </p> <p>I used method swizzling (method_exchangeImplementations) so that instead of calling UIView's initWithFrame, it will call my myInitWithFrame code. The refactoring process threw an error at the method declaration of myInitWithFrame, so I added the <strong>__<em>attribute</em>__</strong>((objc_method_family(init))) after the declaration of the method. Now this all works perfectly fine for iOS 6.0 and above, but on iOS 5.0 (the lowest iOS I would like to support) it doesn't work. I'm getting an EXC_BAD_ACCESS (code=1, address=0X28). On every run the exact same memory address comes up. </p> <p>I have a UIWebView that calls it's:</p> <pre><code>[[UIWebView alloc] initWithFrame:webViewFrame]; </code></pre> <p>After the myInitWithFrame does it's initialization, it returns self, then it crashes. On the thread trace, it says that it crashes in apples's code (the method is greyed out) on the [UIWebView retain] method, as seen below. </p> <pre><code>Thread 1, Queue : com.apple.main-thread #0 0x3515a7d2 in -[UIWebView retain] () #1 0x316ddef4 in objc_retain () #2 0x0011528c in -[UIView(style) myInitWithFrame:] </code></pre> <p>Sorry that the thread trace isn't very well formatted, I don't have enough rep to post an image.</p> <p>Is there any reason why the same code works for iOS 6.0, but not iOS 5.0?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload