2

According to Apple docs, hash value of string may not be stable across different invocations of app:

The hash value is not guaranteed to be stable across different invocations of the same program. Do not persist the hash value across program runs. Apple docs

Is it safe to archive (by NSArchive) dictionary of the following type [String: AnyObject]? If so, how Dictionary prevents from instability? Does it archive dictionary as array of tuples, like [(key, value)]?

Leo Dabus
  • 229,809
  • 59
  • 489
  • 571
squikend
  • 269
  • 2
  • 7
  • 2
    I don't know the answer but thank you for sharing your question, very useful. – Luca Angeletti Jul 29 '16 at 19:14
  • 1
    Interesting question. – Alexander Jul 29 '16 at 19:21
  • Are you asking about the format of an NSKeyedArchiver archive? The warning simply means that you shouldn't store the hashes outside of the dictionary and expect the unarchived dict to have the same hashes when unarchived. It doesn't mean you can't archive a dictionary. – David S. Jul 29 '16 at 19:25
  • 1
    `[String: AnyObject]` is mapped to `NSDictionary` and that conforms to `NSCoding` and thus supports archiving. *How* that is done is an implementation detail. – Martin R Jul 29 '16 at 19:27

0 Answers0