Mac OS X Lion’s “Safe files” No Longer Opens Disk Images

Looks like in Safari 5.1 in Lion disk images (.dmg) are no longer classed as “Safe” files after the whole Mac Defender cat and mouse malware saga.

The enabled by default “Open ‘safe’ files after downloading” preference of Safari automatically opens certain types of files as a convenience aid.

Safari 5.0 on Snow Leopard:

Safari 5.1 on Lion:

I found this quite useful, but I guess it’s just another move closer to an ‘App Store’ only world..

iOS: shouldAutorotateToInterfaceOrientation / Lock Orientation in PhoneGap

Starting in PhoneGap 0.9.5 there’s an undocumented iOS only feature that allows you to handle whether the device should rotate to a particular orientation. It exposes the iOS Objective-C method shouldAutorotateToInterfaceOrientation with a JavaScript function shouldRotateToOrientation.

function shouldRotateToOrientation (rotation) {
    switch (rotation) {
        //Portrait or PortraitUpsideDown
        case 0:
        case 180:
            return true;
        //LandscapeRight or LandscapeLeft
        case 90:
        case -90:
             return false;
    }
}

This needs to be in the global scope of your JavaScript and will get called before any rotations occur, so keep it lean to avoid locking up the UI. Returning true allows the device to rotate, returning false prevents it.

Works great in your HTML5 iOS, iPhone and iPad apps, sadly currently there’s no Android or other platform integration. Hopefully we’ll see a cross-platform method soon!

Avoid Entering Username and Passwords After Restoring iOS

If you restore your iOS (iPhone or iPad) from a backup in iTunes, you’ll find you need to re-enter your usernames and passwords for all your email accounts.

Simply tick the Encrypt iPhone Backups option in the device summary tab in iTunes and enter a password to secure your backups. iTunes will now backup and restore your sensitive data, usernames, passwords and MobileMe data, and do so securely.

Quickly Creating an HTML Link in JavaScript

A cool and little known JavaScript function is .link() available to all string objects. Calling string.link(url) returns an HTML string for an anchor tag with the URL in it. For example:

var text = 'the best website ever';
var html = text.link('http://bencollier.net/'); 
html === "the best website ever" //true

A great way to quickly make links without having to do:

var text = "the best website ever";
var url = "http://bencollier.net/";
var html = "" + text +"" ;
html === "the best website ever" //true

Xcode 4: Unable to Select Project / Template Type

iOS File Template Selector

iOS File Template Selector - unable to click an item


When opening a new iOS or template type in Xcode 4 (4.0.2) I was unable to select any of the project or file templates, turn it out this occurred when tapping (not ‘clicking’) on the items.

Using a firm clicking click or the arrow keys seems to work around this. Tapping just seems to deselect anything currently selected.

What a strange bug!