NSString truncate function for Objective C/iPhone SDK

So far as I can tell, the iPhone SDK exposes no method to truncate an NSString to a given width (in pixels). This function obviously exists since it is used when drawing UILabels, and you can even draw truncated text with the method:
[cc lang=”objc” inline=”true” width=”0″ theme=”geshi”]
– (CGSize)drawInRect:(CGRect)rect withFont:(UIFont*)font lineBreakMode:(UILineBreakMode)lineBreakMode[/cc]
… but there’s no way to read-back the rendered text.

A quick search of the ‘net revealed some methods which would truncate a string based on the number of characters, but nothing to perform the operation based on the rendered width in pixels.

Computer Games Hardware

A comparison of Nintendo DSi XL flash carts

After succumbing to unbearable pressure (e.g. my Mum mentioned in passing that she was thinking about getting one…) and buying one of the new DSi XLs, the next task was to find a solution to playing all of the games I’ve bought since getting my original DS Lite several years ago – without the hassle of carrying around, changing, and then losing hundreds of tiny cartridges.

On the DS Lite, the CycloDS Evolution was pretty much a perfect solution for me – it was fast, stable, customisable, and frequently updated with the latest fixes and upgrades. Unfortunately, it was also completely incompatible with the DSi, and so also the DSi XL.

In order to find an acceptable solution which works on the DSi (and therefore the XL also – the two machines run identical firmware, and only differ physically in form-factor) I ended up ordering one card, and then another – and so it occurred to me that a comparative review could well be useful… especially since one seems to be very popular but really doesn’t work at all well, whilst the other takes some effort to get working but is really very good once it’s sorted out!

Music Politics

Jónsi from Sigur Rós

… on Jo Whiley’s Live Lounge.

“Go Do” starts at 5:38, and the Live Lounge cover track at 15:41.

More from Jónsi here.

Apple Hardware Photography

Apple Time Capsule 500GB Tear-down

Enterprise backup, it ain’t

In December of last year, after only nineteen months of use, my 500GB Time Capsule died of a dead PSU. As documented here (a great graph, sadly lacking a scale on the y-axis…) the average lifespan of a Time Capsule was, for these first generation units, nineteen months and 20 days – and mine was only eighteen days short of this.

In any case, Apple offered to replace my out-of-warranty unit free of charge – but noted that they had no backup service to recover the contents. When asked, they did say that they were happy for me to dismantle the Time Capsule and backup the data myself though. Them’s fightin’ words 🙂

Exit mobile version