Tuesday, April 17, 2012

SVN command line and @2x images

You can't escape it, adding and removing @2x images from the command line don't work. Thanks to a post by behaving on StackOverflow for the solution:


You need to add a "@" sign in the end to get SVN to process the file.
For example, if you had a file called foo@2x.png which you want to add to SVN, you would type:
svn add foo@2x.png@
If you have lots of files with the "@" symbol in their name that you want to process in a batch (i.e. use * wildcard), you can do something like this in OS X Terminal:
find . -name "*@*" | xargs -I % svn add %@
The above command will use the find utility to list out each file with @ in its filename and then pipe the path to the file to SVN using XARGS. XARGS will replace each occurrence of % with the path and append the special "@" at the end of the filename so that SVN will accept it.

Sunday, April 15, 2012

Blocks don't retain variables


I recently had user reports of The Rebus Show crashing in iOS 5.1. The app had been tested and even put through a beta program. The intermittent crash happened because the blocks don't retain variables, in this case myObj was intermittently released by iOS:

    runBlockAfterDelay(delay, ^{
        [myObj myMethod];
        myObj = nil;
    });

The fix was simple:

    __block MyObj* temp = myObj;
    runBlockAfterDelay(delay, ^{
        [temp myMethod];
        temp = nil;
    });

Tracking down this issue was difficult because it was intermittent, crash reports didn't symbolicate this code, ARC was responsible for the object's release, and because the crash manifested itself in an apparently unrelated event handler myMethod was responsible for removing. Fortunately, I noticed the event handler's owner address was different than the current object's address.