Archive for July, 2013

Peopleware 3rd Edition is out

I just found out that the 3rd edition of Peopleware: Productive Projects and Teams was published a few months ago.

It is one of my favorite industry books and I recommend it highly for anyone working in teams or managing teams.

I’ve gotten a quick look and I’m happy that the formatting of the Kindle book is much better this time.  The 2nd edition had a lot of problems with tables and indented quote sections and other formatting.

Solid Coding: Autoresize Masks

UITableView cell contains UILabel set with mask to pin the left and right and allow change to width

If the frame of the cell shrinks past the origin of the UILabel, then the right side of the label will be beyond the right side of the cell frame when it was previously contained entirely inside the frame.

This can be detected with Assertions in the ‘setFrame’ method or you can override the incoming frame to prevent the cell’s frame from shrinking so small that the expansion will be incorrect.

NSTimer Out of Sync with Device Clock?

I encountered this puzzle recently:  How does a 60-second, repeating, NSTimer drift way out of sync with the iPhone’s system clock?  The timer was created with a fireDate that was on the even minute with the clock.  It fires at 11:02:00 AM and 11:03:00 AM, etc.  But users report the timer firing at 1:23:30 PM for example.

(And we are not talking about timers not firing because the run loop mode changed temporarily.)

It turns out that the clue is the word “iPhone”. The NSTimer does not drift from the system clock, the system clock drifts from the NSTimer.  The iPhone can have its clock adjusted during the day by the cellular service, especially if the phone goes out of service and comes back. (Changing locations to a different time zone probably triggers it too.)

You can make it happen by just setting the device clock manually.  When you pic a new time, it jumps to the hour and minute chosen, but with zero seconds.  The iOS honors the repeat rate from the last firing and adjusts the fireDate accordingly.

So if you need to stay tuned to the clock, you’ll need to update the fireDate on the NSTimer when you receive the significant time update notification.

Tags: