NSDictionary与NSDates作为键 [英] NSDictionary with NSDates as keys
本文介绍了NSDictionary与NSDates作为键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有可能有一个NSdictionary,其中的键是NSDates,并且它可写/可归档到磁盘?
Is it possible to have an NSdictionary where the keys are NSDates and also have it writeable/archiveable to disk?
推荐答案
不使用属性列表,因为只允许字符串键。你应该能够使用 NSKeyedArchiver
编写它,但是它的缺点是更不透明的格式。或者,你当然可以做一个字典的副本,你将日期转换为字符串。
Not using property lists, as only string keys are allowed there. You should be able to write it using NSKeyedArchiver
, but that has the disadvantage of being a more opaque format. Alternatively, you could of course make a copy of the dictionary where you convert the dates to strings.
这篇关于NSDictionary与NSDates作为键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文