NSDictionary with NSDates as keys

Is it possible to have NSdictionary, where the keys are NSDates, and also be able to write / archive to disk?

+3
source share
2 answers

Do not use property lists, since only string keys are allowed there. You should be able to write it using NSKeyedArchiver , but it has the disadvantage of being more opaque. In addition, you could, of course, make a copy of the dictionary in which you convert dates to strings.

+6
source

Yes, this should work very well - and NSDate elements are also suitable for plist encoding. Perhaps this depends on the value you entered as the values.

If you are having problems, update your question with the code.

+2
source

Source: https://habr.com/ru/post/1390012/


All Articles