NSDictionary with NSDates as keys

2019-05-14 10:15发布

Is it possible to have an NSdictionary where the keys are NSDates and also have it writeable/archiveable to disk?

2条回答
Juvenile、少年°
2楼-- · 2019-05-14 11:03

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.

查看更多
Explosion°爆炸
3楼-- · 2019-05-14 11:19

Yes, this should work just fine - and NSDate elements are also suitable for plist encoding. Might depend on the value you put in as values, though.

If you experience problems, please update your question with code.

查看更多
登录 后发表回答