Journey's End

Dec 23
2023

On NS*DateFormatters

There now exists NSDateFormatter and NSISO8601DateFormatter and their behaviour when a timezone is not set is not the same: NSDateFormatter produces strings formatted for local time while NSISO8601DateFormatter produces string formatted for UTC.

As an example, given a date-time of 2000-12-31T23:00:00Z

NSDateFormatter with no timezone set and full styles:
Monday, January 1, 2001 at 10:00:00 AM Australian Eastern Daylight Time

NSISO8601DateFormatter with no timezone set:
2000-12-31T23:00:00Z

Note that NSDateFormatter "applies" my local timezone automatically whereas NSISO8601DateFormatter doesn't. Sidebar: it seems that while NSDate carries no timezone information, it is always interpreted as UTC time.

ts=01:16 tags=[objective-c,code]

Apr 12
2016

Method Forwarding in Objective-C Pitfall

A common pitfall of trying to use message forwarding in Objective-C is forgetting to implement

- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector

in addition to

- (void)forwardInvocation:(NSInvocation *)anInvocation

Another problem is that sometimes calling objects will use

- (BOOL)respondsToSelector:(SEL)aSelector

to determine if your proxy object can respond to a particular …