Archive for February, 2009

Relative date to now

Friday, February 20th, 2009 Share on Twitter

In my current project, I needed to know if a given NSDate was today, yesterday or earlier. Simple task, I thought. Until I looked at the documentation for NSCalendar, NSDateComponents and NSDate. While these are extremely powerful, I am not proud of the code I've written. It should be easier. Anyway, ...

Reading the battery level programmatically

Saturday, February 14th, 2009 Share on Twitter

A beta-tester was complaining the application was draining its battery. To check if this was really the case, I needed to get the battery level with a better accuracy than just looking at the battery icon. So I used this little routine to check. This routine is adapted from a post ...