Take the 2-minute tour ×

I've read this post: (NSDateFormatter leak question) which states that NSDateFormatter leaks when the Z is used in the date/time. My date format happens to be as follows: 2011-08-15T22:58:24-07:00

Yet for some reason it's also telling me that NSDate is leaking. Here's the code that's in my init method:

NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[self setCreatedAt:[formatter dateFromString:hCreatedAt]];
[formatter release];

Any ideas on a workaround to this? It would be much appreciated! Just an FYI .. this is ISO 8601 format. I could possibly switch the format if necessary. If that's required, please suggest the proper date/time format I should use.

share|improve this question
There is nothing inherently wrong with this code. Unless setCreatedAt: is poorly behaved, the best I can suggest is to file a bug. –  jtbandes Aug 21 '11 at 3:08
It looks like maybe hCreatedAt might be the problem. Are you sure you are releasing any memory you allocated for that? –  msgambel Aug 21 '11 at 3:43
It appears that if you don't use [formatter setDateFormat:] and [formatter setLocale:] the memory will leak. Really strange, however after those two it appears to work. –  Nick ONeill Aug 21 '11 at 22:29

1 Answer 1

up vote 0 down vote accepted

The solution ended up being that I had to use

[formatter setDateFormat:] //and
[formatter setLocale:]

In order to avoid the memory leak.

share|improve this answer

Your Answer


