Monday 31 October 2011

Setting up Synology DS411J NAS Drive

I recently made the big decision of buying a NAS drive. I have previously relied upon external USB drives and they have been fine up until recently. My previous system was to buy a hard drive, use it until it neared being full, buy a bigger one, copy everything over, stop using the old hard drive (too small by comparison now) and rely fully on the new hard drive. This is madness. If you do this, and you like your data, this is madness. Why? Well, you have everything you own on one hard drive. One drive, which could fail at any moment. Not to scaremonger too much, but I began feeling pretty uneasy about this.

My solution was to buy a NAS box which can hold up to 4 drives. I only bought two hard drives (each 2TB) to go inside the NAS, but the box itself can support up to 12TB. I decided to set this up in a mirroring setup, meaning whatever is added to one drive is automatically written to the other. Obviously then, my 2x2TB hard drives only allow for 2TB storage (and not 4TB) but with the huge and potentially live-saving advantage that if any of the drives failed, there would be a perfect mirror still with all my data intact.

For the NAS drive, I opted for the Synology DS411J (read details on Amazon) and for the hard drives themselves, I opted for Samsung HD204UI Spinpoint 2TB SATA 3.5" Hard Drives (read details on Amazon). Or scroll to the bottom for the Amazon links widget.

Not the ugliest box

Thursday 27 October 2011

iPhone Development - Turn On Automatic Reference Counting (ARC) on a Single File in a Project


Off the back of my other post, Turn Off ARC, which instructs you how to configure Xcode to disable ARC for individual files, this post is the polar opposite; how to enable ARC for individual files.

To enable ARC for a single class, you should go to the "Project Navigator", click on your project, and then select the "Build Phases" tab. From the "Compile Sources" dropdown, find your class on which you wish to enable ARC. Note, you enable this on the .m implementation files, not the .h header files.

Notice that there are two columns here, "Name" and "Compiler Flags". Double click in the relevant "Compiler Flags" column for your desired class, and the following:

-fobjc-arc

Clean and Rebuild your project to pick up these changes. Note, as far as I know, you cannot apply this to whole directories in one go, and have to apply it one file at a time.

Wednesday 26 October 2011

iPhone Development - Turn Off Automatic Reference Counting (ARC) on a Single File in a Project

Xcode has introduced ARC from version 4.2 and above (compatible with iOS 4.0 and above) and it is excellent. All new projects you create will have it enabled by default (you can uncheck this during the new project wizard if you so desire) and that is just lovely.

But what if you need to import legacy code, or another party's source code that hasn't been coded with ARC enabled? You need to remove all manual memory management commands such as release, retain, autorelease etc... if you want to enable ARC. So if your legacy or third party code has these in it and you can't or don't want to edit the code, then you'll have to tell Xcode that ARC is disabled for these files.

Thankfully, Xcode allows you to have ARC enabled for the whole project, but disabled on a select number of files.

To disable ARC for a single class, you should go to the "Project Navigator", click on your project, and then select the "Build Phases" tab. From the "Compile Sources" dropdown, find your class on which you wish to disable ARC. Note, you disable this on the .m implementation files, not the .h header files.

Notice that there are two columns here, "Name" and "Compiler Flags". Double click in the relevant "Compiler Flags" column for your desired class, and the following:

-fno-objc-arc


Clean and Rebuild your project to pick up these changes. Note, as far as I know, you cannot apply this to whole directories in one go, and have to apply it one file at a time.


For details on how to enable ARC for individual files, see my other post, Turn On ARC.

Monday 24 October 2011

Custom HTTP Headers in iPhone UIWebView


If you've done much coding for iPhones, you'll likely have come across the UIWebView class. It is what allows you to use an embeddable web browser component, within your app. It's a useful component that lets you view web pages straight from within your app, using the very capable rendering capabilities granted to the iPhone's full Safari browser.

The problem I faced today, however, was that I needed to customise some of the HTTP headers that are sent to servers, when using the UIWebView component. Turns out that this is possible, although not as straight forward as I first expected. Why might you want to do this? Well you might want to alter the HTTP User Agent string, add some custom headers that your server requires, alter the language supported by the Accept header or you might well just be really curious.

Read the solution after the break.

Thursday 20 October 2011

I Ran a Marathon!

Yes I did. It's true, I have pictures to prove it and everything. On 2nd October, 2011, I participated in the Loch Ness Marathon, some 26.2 miles (~ 42km) of gruelling, undulating, unrelenting hills, unmercifully wearing me down, damaging and breaking my body and spirit. My final time was 5hrs 21mins.

Proof, that certainly couldn't possibly have been photoshopped



A few weeks on though and I've managed to block out exactly how difficult it was. But hopefully in writing this post and looking back at the pictures, I will remember.


Last mile!


Read more after the break.

Sat Nav App for WP7

I recently went looking for a good sat nav software for my Windows Phone. Even with mango, Bing Maps is nothing more than "all right".

Sure it can get me from A to B. But doing so in an easy, safe and convenient manner whilst driving seemed to cause it issues. I mean really, it doesn't update the instructions as you pass them, so the onscreen information is still showing you how to get out your street when you've hit roadworks half way through your journey and need a plan B. And don't even get me started on a lack of turn by turn voice directions.

So I went looking. And sadly found no good free apps. However, I did find a rather spiffingly good app that comes at a cost.