Categories
programming

Strict Date Parsing Gotcha (12 Hour Clock Example)

Be careful when parsing dates from strings. According to Technical Q&A QA1480, dates are parsed depending on a user’s
particular setup, e.g. locale viagra pas cher buy cheap viagra online from india. This happens even though the date format is specified strictly.
To ensure reliable parsing for all users, you need to explicitly set a NSDateFormatter’s locale property.

Example follows for a user that has their clock set to 12 hour:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"HH";
 
// Prints "(null)"
NSLog(@"%@", [dateFormatter dateFromString:@"13"]);    
 
dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
 
// Prints "1970-01-01 12:00:00 PM +0000" on my device
NSLog(@"%@", [dateFormatter dateFromString:@"13"]);
Categories
programming

iOS Development – sizeToFit:

Jérémy Chatard explains the intricacies of UIView’s sizeToFit: with a concrete example of how it should be used to lay out a bunch of subviews stacked vertically. He makes use of recursion in his solution to solve the problem of “If you want to lay out a parent view, you first need to lay out its children” http://canadianviagras.com/pill/cialis-canada/.

If, like me, you always wondered what sizeToFit: should be used for, I recommend you read this. Cheers Jérémy.

Categories
Uncategorized

Huesic Updated

Huesic has been approved and is on the store now, for free of course! See previous post for changelog.

Let’s see how iAd integration works out – I’m not sure how it will display as during development all you see is a test advert, and iAds aren’t released in the UK until september. If anyone can capture a screenshot of iAds working on iOS 4, please send it my way!