<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Get It Down]]></title>
  <link href="http://getitdownonpaper.com/atom.xml" rel="self"/>
  <link href="http://getitdownonpaper.com/"/>
  <updated>2012-01-06T16:39:14-06:00</updated>
  <id>http://getitdownonpaper.com/</id>
  <author>
    <name><![CDATA[Doug Russell]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Comparing to NSNull]]></title>
    <link href="http://getitdownonpaper.com/blog/2012/01/06/comparing-to-nsnull/"/>
    <updated>2012-01-06T12:53:00-06:00</updated>
    <id>http://getitdownonpaper.com/blog/2012/01/06/comparing-to-nsnull</id>
    <content type="html"><![CDATA[<p>Checks to NSNull come up a lot when dealing with things like parsing JSON and while it&#8217;s mostly just ==, there are some options.</p>

<p>The officially sanctioned method is <a href="http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/NumbersandValues/Articles/Null.html#//apple_ref/doc/uid/TP40005153-SW1">NSNull sample code</a>, but this will generate a warning in clang (<strong>BOOO HISSSS</strong>).</p>

<p>So here are the options as I see them:</p>

<pre class="brush: objc">
- (void)someMethod
{
    NSString *aString = @"loremipsum";
    
    // This will complain: "Comparison of distinct pointer types ('NSString *' and 'NSNull *')"
    if (aString != [NSNull null])
    {
        
    }
    
    // This works (at least for strings), but isEqual: does different things 
    // for different classes, so it's not ideal
    if ([aString isEqual:[NSNull null]]) 
    {
        
    }
    
    // If you cast it to the class you're comparing against
    // then you're good to go
    if (aString != (NSString *)[NSNull null])
    {
        
    }
    
    // But we can also just cast it to id and
    // that works generically
    if (aString != (id)[NSNull null])
    {
        
    }
    
    // The thing that would be really cool,
    // would be [NSNull null] returning
    // id (like in the sample category below).
    // Wouldn't count on that one though.
    if (aString != [NSNull idNull])
    {
        
    }
}
</pre>




<pre class="brush: objc">
@interface NSNull (idNull)
+ (id)idNull;
@end
@implementation NSNull (idNull)
+ (id)idNull { return [NSNull null]; }
@end
</pre>


<p>Casting to (id) seems like the simplest way to handle this one, so that&#8217;s the one I&#8217;m using right now.</p>

<p>Update:</p>

<p>One of my coworkers <a href="http://twitter.com/pgor">@pgor</a> pointed out that he uses NSNull&#8217;s isEqual, which seems like a sensible enough thing to do. (I&#8217;m guess Apple isn&#8217;t going to toss anything to screwy into an isEqual on an object that&#8217;s basically single purpose.)</p>

<pre class="brush: objc">
if ([[NSNull null] isEqual:aString]) 
{
        
}
</pre>


<p>Also forgot to mention in the original post: it&#8217;s worth filing a bug against the documentation on NSNull to see what Apple&#8217;s official position is in this post static humiliator world we inhabit.</p>

<p><a href="http://bugreporter.apple.com">Radar</a></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[XXX Timestamps]]></title>
    <link href="http://getitdownonpaper.com/blog/2011/12/22/xxx-timestamps/"/>
    <updated>2011-12-22T23:46:00-06:00</updated>
    <id>http://getitdownonpaper.com/blog/2011/12/22/xxx-timestamps</id>
    <content type="html"><![CDATA[<p>It&#8217;s pretty common to see a timestamp like this</p>

<blockquote><p>2001-07-04T12:08:56-07:00</p></blockquote>

<p>supplied by xml and json feeds.</p>

<p>I&#8217;m pretty sure this is because one of the relatively common <a href="http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html">date formats</a> supported by Java is</p>

<blockquote><p>yyyy-MM-dd&#8217;T&#8217;HH:mm:ssXXX</p></blockquote>

<p>and as we all know, Java and the internet are <a href="http://www.urbandictionary.com/define.php?term=besties">besties</a>.</p>

<p>Thing is, NSDateFormatter doesn&#8217;t know what to do with XXX time zone formats, because it&#8217;s based on <a href="http://unicode.org/reports/tr35/">unicode date formatting</a> and XXX is ISO 8601.</p>

<p>Yay for standards!</p>

<p>Lucky for us we know two things worth knowing</p>

<ul>
<li>there aren&#8217;t half time zones</li>
<li>time format string can escape segments with single quotes</li>
</ul>


<p>so our date format string for our formatter becomes</p>

<blockquote><p>yyyy-MM-dd&#8217;T&#8217;HH:mm:ssZZ&#8217;:00&#8217;</p></blockquote>

<p>and we&#8217;re off to the races.</p>

<p>Everybody&#8217;s happy. Except possibly all those people writing Java.</p>

<p>(Insert your own joke about porn in the app store and XXX time, or maybe something about how our evil Cupertino overlords are censoring our time formatters!)</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Github With Two+ Accounts]]></title>
    <link href="http://getitdownonpaper.com/blog/2011/12/16/github-with-two-plus-accounts/"/>
    <updated>2011-12-16T20:13:00-06:00</updated>
    <id>http://getitdownonpaper.com/blog/2011/12/16/github-with-two-plus-accounts</id>
    <content type="html"><![CDATA[<p>Managing github with two accounts is not obvious. You&#8217;re connecting to the same host, but sometimes you want to use one identity and somethings the other.</p>

<p>This is a balancing act of git configuration and ssh configuration, but it&#8217;s not as bad as it might seem, once you&#8217;re set up.</p>

<!-- more -->


<h3>Setup your accounts</h3>

<p>Create and/or configure the two github accounts you wish to configure</p>

<p>We&#8217;ll refer to them as</p>

<ul>
<li>GithubPersonal</li>
<li>GithubWork</li>
</ul>


<p>and make sure they&#8217;ve each got their own ssh keys configured. (Github has great tutorials on how to generate keypairs and associate them with your account.)</p>

<p>We&#8217;ll assume the keys are</p>

<ul>
<li>~/.ssh/id_rsa_personal &amp; ~/.ssh/id_rsa_personal.pub</li>
<li>~/.ssh/id_rsa_work &amp; ~/.ssh/id_rsa_work.pub</li>
</ul>


<h3>Configure SSH</h3>

<p>If you don&#8217;t have one already create a file called config at ~/.ssh/config</p>

<p>I use textmate, but you could use any text editor.</p>

<pre>
mate ~/.ssh/config
</pre>


<p>We&#8217;ll be setting up config to use aliases when connecting to github using an alias. For example I can setup an alias called work to turn</p>

<pre>
ssh -i ~/.ssh/id_rsa doug@server.example.com
</pre>


<p>into</p>

<pre>
ssh work
</pre>


<p>Our goal is to use aliases to tell git what keypair to use when connecting to github.com</p>

<p>There&#8217;s some flexibility in how you setup the config, you need to set up an alias for at least one of the accounts. I like to alias work and leave my personal account untouched, but a more thorough invidual might do both. This will become clearer as we proceed.</p>

<pre>
Host personal
    Hostname github.com
    User git
    IdentityFile ~/.ssh/id_rsa_personal
Host work
    Hostname github.com
    User git
    IdentityFile ~/.ssh/id_rsa_work
</pre>


<p>Now we&#8217;ll get the keypairs loaded so the system will use them</p>

<pre>
# Clear out currently stored identities
ssh-add -D
# Add in personal key (you may be prompted for your keypairs password)
ssh-add ~./ssh/id_rsa_personal
# And work
ssh-add ~./ssh/id_rsa_work
# Print a list of loaded keys to make sure both are loaded
ssh-add -l
</pre>


<p>Now you&#8217;ve got your keys in place, let&#8217;s poke github and see if it recognizes us</p>

<pre>
ssh -T personal
</pre>


<p>Should give you</p>

<blockquote><p>Hi GithubPersonal! You&#8217;ve successfully authenticated, but GitHub does not provide shell access.</p></blockquote>

<p>Same for work</p>

<pre>
ssh -T work
</pre>


<p>Should give you</p>

<blockquote><p>Hi GithubWork! You&#8217;ve successfully authenticated, but GitHub does not provide shell access.</p></blockquote>

<p>So now we&#8217;re up and running and doing the ssh tango, onto the next one.</p>

<h3>Configure Git</h3>

<p>Git can be configured with a username, email address and custom fields. Github recommends using the custom fields to add in your github username and your github token.</p>

<pre>
# Check your current globals
git config --global -l
</pre>


<p>They should look something like</p>

<blockquote><p>  user.name = Some Guy</p>

<p>  user.email = someguy@example.com</p>

<p>  core.excludesfile = /Users/someguy/.gitignore</p>

<p>  mergetool.keepbackup = true</p>

<p>  github.username = GithubPersonal</p>

<p>  github.token = 123456789asdjfhlkjhdflkh8598</p></blockquote>

<p>I choose to configure my globals to use my personal account, becaues I have a lot more active repos in my personal account than my work account.</p>

<p>You can configure any of the setting with the following syntax</p>

<pre>
git config --global user.name "Some Guy"
</pre>


<p>by swapping out the name of the property and it&#8217;s value.</p>

<p>I recommend setting user.name, user.email, github.username, and github.token.</p>

<p>Now you&#8217;re configured for general use. We&#8217;ll revisit local configs after we cover cloning repos.</p>

<h3>Getting your code</h3>

<p>Normally you&#8217;d go to the github project site and grab the clone URL and be off to the races.</p>

<p>Something like</p>

<pre>
git clone git@github.com:username/repo.git
</pre>


<p>and if you have permission you can push/pull/etc from that repo.</p>

<p>In this case we need to tell github what we&#8217;re doing so we change the syntax some</p>

<pre>
git clone ssh://work/username/repo.git
</pre>


<p>would pull down the repo using the ssh keypair for you work account.</p>

<p>The logic is the same to use your personal account</p>

<pre>
git clone ssh://personal/username/repo.git
</pre>


<h3>Git Config Local</h3>

<p>Now that you&#8217;ve got some code to work with, the last thing to fix is making sure that your commits show up on github accredited to the right account. Git will automatically use the global config for any keys you don&#8217;t override on a per repo basis.</p>

<p>You do have to do this for each repo you clone, but only once per repo.</p>

<pre>
cd repo
# Check your current local config
git config --local -l
</pre>


<blockquote><p>  core.repositoryformatversion = 0</p>

<p>  core.filemode = true</p>

<p>  core.bare = false</p>

<p>  core.logallrefupdates = true</p>

<p>  core.ignorecase = true</p>

<p>  remote.origin.fetch = +refs/heads/<em>:refs/remotes/origin/</em></p>

<p>  remote.origin.url = ssh://work/username/repot.git</p>

<p>  branch.master.remote = origin</p>

<p>  branch.master.merge = refs/heads/master</p></blockquote>

<p>Again I recommend setting user.name, user.email, github.username, and github.token, but this time use your work account.</p>

<p>You&#8217;ll end up with a few new lines in your local config when you&#8217;re done</p>

<blockquote><p>  user.name = Some Guy</p>

<p>  user.email = workemail@example.com</p>

<p>  github.username = GithubWork</p>

<p>  github.token = 3235435468413asdsfdasdfsfs</p></blockquote>

<h3>All Done</h3>

<p>That&#8217;s the whole show. You can now configure aliases and local configs to make sure the right projects are using the right accounts and right metadata.</p>

<p>Hope this is useful.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Making NSAssert Play Nice With Blocks]]></title>
    <link href="http://getitdownonpaper.com/blog/2011/09/27/making-nsassert-play-nice-with-blocks/"/>
    <updated>2011-09-27T23:55:00-05:00</updated>
    <id>http://getitdownonpaper.com/blog/2011/09/27/making-nsassert-play-nice-with-blocks</id>
    <content type="html"><![CDATA[<p>NSAssert is actually a macro that calls <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSAssertionHandler_Class/Reference/Reference.html">NSAssertionHandler</a> using the <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSAssertionHandler_Class/Reference/Reference.html">handleFailureInMethod:object:file:lineNumber:description</a> method with self as the argument for object. This is fine and dandy for most asserts, but if you&#8217;re in a block, you probably just made a retain cycle.</p>

<p>Luckily this is pretty easy to fix by logging the function instead of the object:</p>

<pre class="brush: objc">
#if !defined(NS_BLOCK_ASSERTIONS)

#define BlockAssert(condition, desc, ...) \
do {\
if (!(condition)) { \
[[NSAssertionHandler currentHandler] handleFailureInFunction:NSStringFromSelector(_cmd) \
file:[NSString stringWithUTF8String:__FILE__] \
lineNumber:__LINE__ \
description:(desc), ##__VA_ARGS__]; \
}\
} while(0);

#else // NS_BLOCK_ASSERTIONS defined

#define BlockAssert(condition, desc, ...) 

#endif
</pre>


<p>This new macro behaves the same and will compile out with the same flags as NSAssert.</p>

<p>Easy, Peasy.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Keeping Count With OSAtomic]]></title>
    <link href="http://getitdownonpaper.com/blog/2011/09/27/keeping-count-with-osatomic/"/>
    <updated>2011-09-27T13:02:00-05:00</updated>
    <id>http://getitdownonpaper.com/blog/2011/09/27/keeping-count-with-osatomic</id>
    <content type="html"><![CDATA[<p>OSAtomic is a many splendored thing, with many low level functions to simplify manipulating your data in a thread safe manner.</p>

<p><a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/KernelIOKitFramework/OSAtomic_h/index.html">OSAtomic</a></p>

<p>One of the things it does best is make integer math really easy to do without the weight of a general purpose lock.</p>

<p>Here&#8217;s a dead simple counter that just bumps an integer on each access:</p>

<pre class="brush: objc">
#import &lt;Foundation/Foundation.h>
#import &lt;libkern/OSAtomic.h>

static int32_t _count = 0;
static inline int32_t MonotonicCounter(void)
{
    return OSAtomicIncrement32(&_count);
}
</pre>


<p>OSAtomic is worth spending some time with, there&#8217;s lots of goodies.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Accessible Buttons]]></title>
    <link href="http://getitdownonpaper.com/blog/2011/09/21/accessible-buttons/"/>
    <updated>2011-09-21T17:23:00-05:00</updated>
    <id>http://getitdownonpaper.com/blog/2011/09/21/accessible-buttons</id>
    <content type="html"><![CDATA[<p>Apple provides an astonishingly good framework for making iOS apps equally useful to sighted and unsighted users.</p>

<p>Some preliminary reading if you&#8217;re interested:</p>

<ul>
<li><a href="http://mattgemmell.com/2010/12/19/accessibility-for-iphone-and-ipad-apps/">Matt Legend Gemmell - Accessibility for iPhone and iPad Apps</a></li>
<li><a href="http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/iPhoneAccessibility/Introduction/Introduction.html">Accessibility Programming Guide for iOS</a></li>
</ul>


<p>I&#8217;d like to offer a short take on one of the most common mistakes that iOS developers make when they&#8217;re not thinking about accessibility, Buttons.</p>

<p>UIButton instances can be a configured a lot of ways:</p>

<ul>
<li>With text</li>
<li>With text and an image</li>
<li>With just an image</li>
<li>With custom drawing</li>
<li>Etc</li>
</ul>


<p>I&#8217;ve created a <a href="https://github.com/EverythingSolution/ESAccessibility/tree/master/AccessibleButtons">sample project</a> that you can grab to see how buttons can be configured to make sure that iOS&#8217;s Voice Over framework can see what that buttons content and purpose is.</p>

<p>Grab the code, give it a look, and remember these takeaways:</p>

<ul>
<li>Set the buttons title any time you can</li>
<li>If you can&#8217;t set the buttons title, set its accessibilityLabel</li>
<li>A picture of text, is not the same as text if you&#8217;re not sighted</li>
</ul>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Objective-C Object Mapping]]></title>
    <link href="http://getitdownonpaper.com/blog/2011/09/19/objective-c-object-mapping/"/>
    <updated>2011-09-19T18:50:00-05:00</updated>
    <id>http://getitdownonpaper.com/blog/2011/09/19/objective-c-object-mapping</id>
    <content type="html"><![CDATA[<p>I think basically any Objective-C developer who has spent some time on the platform has written a half dozen different ways to turn a dictionary into a model object:</p>

<pre class="brush: objc">
SomeModelObject *model = [[SomeModelObject alloc] init];
model.someProperty = [someDictionary objectForKey:@"someProperty"];
//etc
</pre>


<p>or a little better</p>

<pre class="brush: objc">
@implementation SomeModelObject
- (id)initWithDictionary:(NSDictionary *)dictionary
{
    self = [super init];
    if (self)
    {
        self.someProperty = [dictionary objectForKey:@"someProperty"];
    }
    return self;
}
</pre>


<p>and then there&#8217;s transformations, like turning a string into a date, etc.</p>

<p>While I was at <a href="http://bottlerocketapps.com">Bottle Rocket</a>, we decided to formalize this process and write something that would make it easy and consistent to turn dictionaries into model objects and back into dictionaries.</p>

<p>When I left Bottle Rocket, I had gotten so used to having this tool at my disposal I decided, with BR blessing, to build my own.</p>

<p><a href="https://github.com/EverythingSolution/ESObjectMap">ESObjectMap</a> is my 2.0 take on this problem:</p>

<ul>
<li>Easy configuration from a dictionary for native model objects and core data objects</li>
<li>Mismatched field name mapping</li>
<li>Built in basic data transforms for common data types and an easy path to build custom transforms</li>
<li>Mapping of native model objects back into dictionaries</li>
</ul>


<p>Couple of non-feature side notes:</p>

<ul>
<li>Written for ARC</li>
<li>While the samples are of rendering to and from JSON, this is really just about dictionaries to objects and back</li>
<li>Uses my <a href="http://getitdownonpaper.com/journal/2011/9/14/objective-c-declared-property-introspection.html">property introspection</a> logic, so you have lots of meta data to work with when performing mappings and transforms.</li>
</ul>


<p>Check out the sample project, let me know what you think. I&#8217;m pretty happy with where it is now, but there&#8217;s always room for improvement.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Objective-C Declared Property Introspection]]></title>
    <link href="http://getitdownonpaper.com/blog/2011/09/14/objective-c-declared-property-introspection/"/>
    <updated>2011-09-14T18:15:00-05:00</updated>
    <id>http://getitdownonpaper.com/blog/2011/09/14/objective-c-declared-property-introspection</id>
    <content type="html"><![CDATA[<p>Here&#8217;s a fun little NSObject category that allows you  to pop out an object&#8217;s declared properties into a dictionary keyed by the property names.</p>

<p><a href="https://github.com/EverythingSolution/UsefulBits/tree/master/NSObject+PropertyDictionary">NSObject+PropertyDictionary</a></p>

<p>The values in the dictionary are ESDeclaredPropertyAttributes objects that should give you most of the data you&#8217;d want for most kinds of properties most of the time. (A comprehensive object that gives you all the possible data stored into a declared properties would be a complicated kitchen sink and only marginally more usable)</p>

<pre class="brush: objc">
typedef enum {
    AssignStorage, // assign is the default declared property setter type
    StrongStorage,
    CopyStorage,
    ReadOnlyStorage
} PropertyStorageMethod;

// Not going to try to support
// enum, struct, union, int *, void *, long, short, signed, unsigned, etc
typedef enum
{
    IDType,
    ObjectType,
    CharType,
    DoubleType,
    FloatType,
    IntType,
    UnsupportedType
} PropertyStorageType;

@interface ESDeclaredPropertyAttributes : NSObject

@property (strong, nonatomic) NSString *classString;
@property (strong, nonatomic) NSString *name;
@property (nonatomic) PropertyStorageType storageType;
@property (nonatomic) SEL getter;
@property (nonatomic) SEL setter;
@property (nonatomic) PropertyStorageMethod storageMethod;
@property (nonatomic) BOOL readOnly;
@property (nonatomic) BOOL nonatomic;
@property (nonatomic) BOOL dynamic;

@end
</pre>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Sync Followup]]></title>
    <link href="http://getitdownonpaper.com/blog/2011/09/03/sync-followup/"/>
    <updated>2011-09-03T21:44:00-05:00</updated>
    <id>http://getitdownonpaper.com/blog/2011/09/03/sync-followup</id>
    <content type="html"><![CDATA[<p>I thought I&#8217;d follow my post about concurrency with a simple example that actually uses it:</p>

<p><a href="https://github.com/EverythingSolution/UsefulBits/blob/master/ESMutableDictionary.h">ESMutableDictionary.h</a></p>

<p><a href="https://github.com/EverythingSolution/UsefulBits/blob/master/ESMutableDictionary.h">ESMutableDictionary.m</a></p>

<p>This isn&#8217;t an NSMutableDictionary subclass as you might expect, it&#8217;s a very simple wrapper around a CFMutableDictionary which presents only the most basic interface to manipulating membership in the collection and retrieving current members of the collection.</p>

<pre class="brush: objc">
@interface ESMutableDictionary : NSObject

- (id)init;
- (void)setObject:(id)obj forKey:(id)key;
- (void)removeObjectForKey:(id)key;
- (id)objectForKey:(id)key;

- (NSDictionary *)copyDictionary;

@end
</pre>


<p>What it is:</p>

<ul>
<li>An easy to use, reasonably performant, key value store that can have values added, removed and retrieved from multiple threads simultaneously.</li>
</ul>


<p>What it is not:</p>

<ul>
<li>A wholesale replacement for NSMutableDictionary.

<ul>
<li>The concurrency considerations make this collection significantly less performant than a plain dictionary in any situation where there isn&#8217;t need for concurrency.</li>
<li>Many of the functions that make NSDictionary so useful are not available, because making them concurrent and still being performant would be challenging.</li>
</ul>
</li>
<li>Protection against mutating members of the collection. If you toss an object into this collection and then two threads try to changes it&#8217;s properties simultaneously, it&#8217;s on you to handle that, not this collection.</li>
</ul>


<p>Copy Dictionary:</p>

<p>This is offered as a way to pop out the current collection so that it can be manipulated or enumerated or etc. It&#8217;s a shallow copy, but it should do the trick for most applications.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Sync]]></title>
    <link href="http://getitdownonpaper.com/blog/2011/08/27/sync/"/>
    <updated>2011-08-27T14:44:00-05:00</updated>
    <id>http://getitdownonpaper.com/blog/2011/08/27/sync</id>
    <content type="html"><![CDATA[<p>So if you&#8217;ve ever written any concurrent software you&#8217;ve had to do some kind of acrobatics to create a <a href="http://en.wikipedia.org/wiki/Critical_section">Critical Section</a>.</p>

<blockquote><p>&#8220;You have to use (OSAtomic || NSRecursiveLock || @synchronized() || FloppyRubberChicken or you&#8217;re doing it wrong&#8221;
- The Entire Internet (AKA Stack Overflow)</p></blockquote>

<ol>
<li><p>If your logic is written in a way that resource contentions are really a serious ding to your performance, then maybe you need to step back and think about solving things other than how fast your code locks and unlocks.</p></li>
<li><p>I do it with dispatch_sync, not because it&#8217;s the (Best || Most Perfect || Infallible || Unquestionable) approach possible, but because it&#8217;s simple, reliable, and in my experience fast. This may change, and when it does I&#8217;ll change to. For now this is how I do business: <a href="https://gist.github.com/1175800">GIST</a></p></li>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Beat Up In High School]]></title>
    <link href="http://getitdownonpaper.com/blog/2011/07/30/beat-up-in-high-school/"/>
    <updated>2011-07-30T23:41:00-05:00</updated>
    <id>http://getitdownonpaper.com/blog/2011/07/30/beat-up-in-high-school</id>
    <content type="html"><![CDATA[<p>We&#8217;ve all seen this:</p>

<pre class="brush: objc">
[newObject retain];
[object release], object = nil;
object = newObject;
</pre>


<p>or this:</p>

<pre class="brush: objc">
- (void)dealloc
{
    [object release], object = nil;
    [super dealloc];
}
</pre>


<p>I always see people who set things to nil right before they set them to something else or right before they cease to exist as people who just want exc_bad_access to stop punching them and they&#8217;ve adopted irrational coping mechanisms.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Don't Do This]]></title>
    <link href="http://getitdownonpaper.com/blog/2011/07/30/dont-do-this/"/>
    <updated>2011-07-30T22:54:00-05:00</updated>
    <id>http://getitdownonpaper.com/blog/2011/07/30/dont-do-this</id>
    <content type="html"><![CDATA[<pre class="brush: objc">
self.someProperty = [[SomeClass alloc] init];
[self.someProperty release];
</pre>


<p>This is that frustrating kind of wrong where it doesn&#8217;t crash or leak, so it can sometimes make for a hard sell.</p>

<p>If the object has a setter, use the setter, except in init and dealloc. It hinders your flexibility to change memory semantics and it violates owning naming conventions, you&#8217;re getting back an autoreleased object, not a +1 object. It&#8217;s probably going to work like 99% of the time, but it&#8217;s not ok.</p>

<p>Don&#8217;t do it.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Why Do Apps Crash?]]></title>
    <link href="http://getitdownonpaper.com/blog/2011/07/30/why-do-apps-crash/"/>
    <updated>2011-07-30T20:52:00-05:00</updated>
    <id>http://getitdownonpaper.com/blog/2011/07/30/why-do-apps-crash</id>
    <content type="html"><![CDATA[<blockquote><p>It&#8217;s very easy to make an app that works great in your office on Wi-Fi&#8230;&#8230;&#8230;</p></blockquote>

<p>When they quote Calvin, he&#8217;s quoting me, which I&#8217;m pretty sure makes me more famous than Oprah.</p>

<p><a href="http://getitdownonpaper.squarespace.com/journal/2011/7/30/why-do-apps-crash.html#references">Popular Mechanics</a></p>
]]></content>
  </entry>
  
</feed>

