<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Engineering in a startup - Medium]]></title>
        <description><![CDATA[hacking on pigs until they fly. - Medium]]></description>
        <link>https://medium.com/engineering-in-a-startup?source=rss----d7a43d2c7bf6---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Engineering in a startup - Medium</title>
            <link>https://medium.com/engineering-in-a-startup?source=rss----d7a43d2c7bf6---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 02:54:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/engineering-in-a-startup" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Apple ❤ Zombies]]></title>
            <link>https://medium.com/engineering-in-a-startup/apple-zombies-c7b348d8014d?source=rss----d7a43d2c7bf6---4</link>
            <guid isPermaLink="false">https://medium.com/p/c7b348d8014d</guid>
            <dc:creator><![CDATA[Daniel Spinosa]]></dc:creator>
            <pubDate>Thu, 07 Nov 2013 17:56:55 GMT</pubDate>
            <atom:updated>2013-11-07T18:12:14.883Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*2XFNjZR_C8Iv-9FBF9he-g.jpeg" /></figure><h4>or How I learned to stop worrying about EXC_BAD_ACCESS and work around Apple’s bug.</h4><p>When your app crashes, it’s your fault. Normally that means you did something dumb. But sometimes it means Apple did something dumb and <em>you forgot to work around it</em>. That happens to be the case with <strong>UIScrollView</strong>’s delegate and me.</p><p>The situation was all too familiar: occasional crash reports without useful stack information providing no help reproducing or fixing the crash. Fortunatley, I stepped in shit while debugging something else and could reproduce the <strong>EXC_BAD_ACCESS</strong> on command.</p><blockquote>Zombies, like farts, are often silent but deadly. Thankfully Xcode has <strong>NSZombieEnabled</strong> to help clear the air.</blockquote><p>Turning on <strong>NSZombieEnabled</strong> made it obvious: the delegate of my scroll view was being sent a message from<em> </em>the scroll view <em>after</em> it was deallocated. This is, of course, impossible with ARC; weak refernces to the delegate are set to <strong>nil</strong> when the delegate is deallocated. Only, it was possible. I was watching it happen.</p><p>Somewhere in the depths of the framework, Apple is holding an <strong>__unsafe_unretained</strong> reference to the delegate. Those don’t get set to <strong>nil</strong> when the object is deallocated, hence the <em>unsafe</em> part. The <strong>delegate</strong> property of <strong>UIScrollView</strong> is certainly <strong>weak</strong>, or this would blow up all the time. So, where is the problem? I don’t know for sure, but I have some idea where this pointer is dangling…</p><blockquote><em>Dan: 1 — Zombies: 1 (a tie goes to the coder) </em><a href="https://github.com/spinosa/DSZombieScroll"><em>https://github.com/spinosa/DSZombieScroll</em></a></blockquote><p>Calling <strong>[someScrollView setContentOffset:offset animated:YES]</strong> and then immediately deallocating the delegate (ie. before the animation is complete) produces the crash. To see it in action for yourself, check out my little example: <a href="https://github.com/spinosa/DSZombieScroll">DSZombieScroll</a>. It seems that Apple hangs on to the <strong>__unsafe_unretained</strong> pointer during the animation.</p><p>The workaround depends on your situation,but it’s probably simple. For my fix in the <a href="http://shelby.tv/">Shelby</a> codebase, I just rearranged the order of deallocation.</p><p>My relationship status with Apple remains love/hate. Which is usually a pretty big number.</p><p>Radar # 15403528</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*ZQdxaVOtMjyO0FnQeqRlqw.png" /><figcaption>Dan ♥ XKCD</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7b348d8014d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/engineering-in-a-startup/apple-zombies-c7b348d8014d">Apple ❤ Zombies</a> was originally published in <a href="https://medium.com/engineering-in-a-startup">Engineering in a startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>