'Mac' Category

Unhide ~/Library in Mac OS X Lion 10.7 [Take Two]

As many people have no doubt noticed by now, Mac OS X 10.7 hides your Library folder by default in the Finder. For power users, developers and other such creatures in regular need of the Library, this means a trip to the Terminal, which seems like a step backwards (to me, at least).

There has been a hack floating around to reenable hidden folders which I detailed here, however it really goes too far, enabling the whole Unix filesystem for view in the Finder.

A more useable alternative uses the ‘chflags’ command, and can be invoked with the following:

$ chflags nohidden ~/Library

Solving the MBProgressHud _WebTryThreadLock Error

MBProgressHud is a really nice bit of plug in code to add fancy status and loading notifications to your iOS app quickly and easily. It looks great! Unfortunately, there’s an irritating error which cost me some time this morning, and hopefully I can save anyone else in the same position some trouble.

The error:

bool _WebTryThreadLock(bool), 0x7b9b5500: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...

This appears when a method which needs to update a UI component is called directly by the MBProgressHUD object.

The most basic usage of MBProgressHUD is thus:

HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD];
HUD.delegate = self;
[HUD showWhileExecuting:@selector(fetchNewData) onTarget:self withObject:nil animated:YES];

In which ‘fetchNewData’ is the method which is executed while the progress HUD is on display.

Using this technique, fetchNewData will be called on a secondary thread, which causes the crash error we’ve already experienced. UIKit, which handles all the user interface business, should only be running on the main thread, so when the secondary thread makes a move on a particular UI element, its going to throw the ‘web lock from a thread…’ error. (It should be noticed that you can update some UI components using the standard MBProgressHUD setup detailed above, but in most cases you’ll get the error.)

In the case of this example, ‘fetchNewData’ updates part of the UI, so it needs to be called on the main thread. The quick and dirty workaround I used to force it to execute where I wanted it to was to create an intermediary method which can be called by MBProgressHUD as normal but in turn calls ‘fetchNewData’ specifically on the main thread.

You could, for example, call this method ‘performFetchOnMainThread’:

-(void) performFetchOnMainThread    {
[self performSelectorOnMainThread:@selector(fetchNewData) withObject:nil waitUntilDone:YES];
}

Instead of directly calling ‘fetchNewData’ from MBProgressHUD, use it to execute ‘performFetchOnMainThread’, which uses the ‘performSelectorOnMainThread’ method to force ‘fetchNewData’ to be executed on the main thread.

This isn’t the most efficient or beautiful way to accomplish this, but it works, so if you’re getting a ‘web lock from a thread…’ error and you need to make sure your code is executed on the main thread, you can use this technique to get the job done quickly.

PC Keyboards in Mac OS X Lion

One of the benefits of the recent upgrade I made to Mac OS X 10.7 Lion is how consistently simple using a PC keyboard now is. The preference pane for switching the modifier keys around (using alt in place of CMD, Windows key in place of option etc…) was available in Snow Leopard and earlier versions, but compatibility with the range of PC keyboards I’ve tried with my various Macs has long been a bit patchy – even though the changes would save in System Preferences, the keys would still use the default mapping.

If you’re used to CMD being either side of the space bar, it can get pretty annoying when it isn’t there.

In earlier versions of OS X, I’ve used DoubleCommand when there’s been trouble remapping keys, however I’m pleased to report that Lion seems to have addressed some of the earlier issues with the modifier preference pane being ineffective.

I’ve tested the modifiers with a range of keyboards (including ones I’ve experienced issues with in the past) and they all seem to be altering the maps without issue.

To alter the key map:

1. Open System Preferences and select the ‘Keyboard’ preference pane

2. Click the ‘Modifier Keys’ button and switch the mapping. When you’re done, click ‘OK’ and close the preference pane.

Colorshare – Available in the App Store

Hot off the presses and approved by Apple mere moments ago, colorshare will become available in regional iPhone App Stores the world over over the next 48 hours or so.

Colorshare is a simple utility which allows you to quickly design a palette of colours on your iPhone or iPod Touch and with the tap of a button share it with the web using the unique palette ID number, which you can punch right into the colorshareapp.com homepage.

Once you’ve entered the ID of the palette you want to work with, it will appear on screen alone with a full breakdown of each colour in RGB, hexadecimal and CMYK.

Colorshare is completely free, and you can grab it from the App Store by following this link.

TWiT Early Show Downloader

For me, TWiT network is one of the most valuable resources on the internet: their programming is always informative, slick and balanced, and the guests are always top-teir tech talkers.

As with most pod/netcasts broadcast from the States, the scheduling of live shows is always at pretty peculiar hours of the day thanks to the time difference, which means waiting for the edited version to be uploaded and published to the TWiT website.

Handily, the editors seem to work much quicker than the web folks over in Petaluma, CA, and the shows are normally uploaded quite a bit earlier than they are listed on the website. I’ve been using a little Python program which I wrote to download the shows before they are linked on the site, which you can grab using the instructions below. It uses cURL to download the files so it’ll work on Macintosh and Linux systems.

(more…)

Restore Hidden Files to OS X 10.7 Lion Finder

One step Lion takes in the direction of erasing the file system altogether is hiding the Library, System and other OS- and user-crucial directories in the Finder.

Obviously as power users we’re fully used to delving into the (already abstracted) file system of Mac OS X, and we want those folders back! Via this site, there is a Terminal command to restore access to these directories, but be warned that it comes with a caveat: by enabling access to these folders, you open up the whole filesystem including UNIX folders (etc, var…) and DS_Store files for view in the Finder.

In short, it’s way annoying, especially when browsing Linux volumes.

Irritating as having bits of the filesystem whipped away from prying eyes, I think I’m going to stick with Terminal for accessing those folders. TextWrangler can still browse them, and that’s enough for me. For those who want to see everything, and I mean everything:

$ defaults write com.apple.Finder AppleShowAllFiles YES

iPhone App Preview – colorshare

Coming soon to the web and the iPhone, a very quick and very easy way to prototype color schemes and share them online. ‘colorshare’ is currently in testing, but it should soon be available on the iOS App Store as a free download.

Meanwhile, the future home of the application on the web is online already, with features (beyond a placeholder) coming soon.

Ghosts at New Apple HQ?

Apple’s renderings of their proposed new headquarters have surfaced online at the City of Cupertino website in the form of a high-res PDF, yielding more details of the beautiful building itself as well as the surprising revelation that the grounds will apparently be patrolled by ghosts (have you ever seen a head that see-through?)

In all seriousness, while the confusing mix of transparent and solid bodied employees in the renderings is probably just an oversight on the part of a designer, the construction itself looks incredible. I’ve been looking forward to seeing it up-close since Steve presented it to the city council a couple of months ago and it looks every bit as good as expected. There are many breathtaking skyscrapers across the globe but I can’t recall a sprawl this spectacular. Is there any chance this place won’t become iconic?

RAM Disk vs SSD vs Hard Disk – The Photoshop Test

A few weeks ago I posted the Macintosh version of ‘rdmanage’, my super-simple Unix RAM disk creation tool, as well as stacking the volatile disks up against fixed hard drives in a Linux I/O benchmark shootout. One thing which has always bothered me about synthetic benchmarking, however, is how far removed it is from most real-life computing contexts.

In order to realistically demonstrate the advantages and disadvantages of the three main types of disk – RAM drive, hard drive and solid state – I’ve prepared a short video of a basic Photoshop loading test, embedded after the break.

I’m a huge fan of solid state disks (the X25-M is one of my all time favourite pieces of computer hardware), but due to their high price and limited capacity they aren’t a complete no-brainer just yet. Using something like ‘rdmanage’ to easily create RAM disks, users of machines with hard disk drives can get a serious boost in application load time (as demonstrated in this Photoshop loading test) without having to spend a dime extra on hardware. The SSD is still the winner in my book, but if you can spare a couple of hundred meg of RAM you can get some of the perks with zero additional cost.

(more…)

Mac OS X 10.7 Lion iTunes Widget Download

 

Whilst Java was actually pretty easy to load and X11 is installed by default, one thing definitely missing from Mac OS X 10.7 Lion is the iTunes widget. I use the iTunes widget all the time, so it was pretty annoying that it was not included with Lion.

I pulled the widget file from a Snow Leopard install I have on another machine and, thankfully, it works perfectly with the dashboard on Lion.

For anyone also missing the iTunes widget in Lion, you can download it here.

[Legal: I’m not the copyright holder or the original author of this file]