Associative Storage

It organizes data and keys so that data can be quickly and easily accessed using the corresponding keys. Associative Storage promotes flexibility and runtime storage efficiency.

The objects stored in a dictionary are retained when they are added to the collection and released when they are removed. The keys that are added to a dictionary are copied, which means that all objects used as keys in a dictionary must conform to the NSCopying formal protocol declared in NSObject.h. In addition to conforming to the NSCopying protocol, objects used as keys in a dictionary must implement the -isEqual: and -hash methods so that any two objects that are considered equal by the -isEqual: method also have the same hash value. The -isEqual: and -hash methods are declared in the NSObject class, which provides basic implementations using the address of objects. In other words, two objects are equal if they have the same address, and the -hash value is computed from the address.

posted on 2012-07-08 14:18  grep  阅读(145)  评论(0编辑  收藏  举报