NSDateFormatter内存泄漏问题 [英] NSDateFormatter Memory Leak Issue

查看:74
本文介绍了NSDateFormatter内存泄漏问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了这篇文章:( NSDateFormatter泄漏问题)指出了NSDateFormatter泄漏在日期/时间中使用Z时.我的日期格式刚好如下:2011-08-15T22:58:24-07:00

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

但是由于某种原因,它也告诉我NSDate正在泄漏.这是我的init方法中的代码:

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];

有任何解决方法的想法吗?将不胜感激!仅供参考,这是ISO 8601格式.如有必要,我可以切换格式.如果需要,请提出我应该使用的正确日期/时间格式.

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.

推荐答案

解决方案最终是我不得不使用

The solution ended up being that I had to use

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

为了避免内存泄漏.

这篇关于NSDateFormatter内存泄漏问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆