![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/share/doc/gnustep-base-doc/Base/Reference/ |
Upload File : |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>NSDictionary class reference</title> </head> <body> <font face="serif"> <a href="Base.html">Up</a> <br /> <h1><a name="title$NSDictionary">NSDictionary class reference</a></h1> <h3>Authors</h3> <dl> <dt>Andrew Kachites McCallum (<a href="mailto:mccallum@gnu.ai.mit.edu"><code>mccallum@gnu.ai.mit.edu</code></a>)</dt> <dd> </dd> <dt>Adam Fedor (<a href="mailto:fedor@boulder.colorado.edu"><code>fedor@boulder.colorado.edu</code></a>)</dt> <dd> </dd> </dl> <p><b>Copyright:</b> (C) 1995, 1996, 1997 Free Software Foundation, Inc.</p> <div> <hr width="50%" align="left" /> <h3>Contents -</h3> <ol> <li> <a href="#001000000000">Software documentation for the NSDictionary class</a> </li> <li> <a href="#002000000000">Software documentation for the NSMutableDictionary class</a> </li> </ol> <hr width="50%" align="left" /> </div> <h1><a name="001000000000"> Software documentation for the NSDictionary class </a></h1> <h2><a name="class$NSDictionary">NSDictionary</a> : <a rel="gsdoc" href="NSObject.html#class$NSObject">NSObject</a></h2> <blockquote class="declared"> <dl> <dt><b>Declared in:</b></dt> <dd>Foundation/NSDictionary.h</dd> </dl> </blockquote> <blockquote> <dl> <dt><b>Conforms to:</b></dt> <dd><a rel="gsdoc" href="NSObject.html#protocol$(NSCoding)">NSCoding</a></dd> <dd><a rel="gsdoc" href="NSObject.html#protocol$(NSCopying)">NSCopying</a></dd> <dd><a rel="gsdoc" href="NSObject.html#protocol$(NSMutableCopying)">NSMutableCopying</a></dd> <dd><a rel="gsdoc" href="NSEnumerator.html#protocol$(NSFastEnumeration)">NSFastEnumeration</a></dd> </dl> </blockquote> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> </p> <p> This class and its subclasses store key-value pairs, where the key and the value are objects. A great many utility methods for working with dictionaries are provided as part of this class, including the ability to retrieve multiple entries simultaneously, obtain sorted contents, and read/write from/to a serialized representation. </p> <p> </p> <p> The keys are copied and values are retained by the implementation, and both are released when either their entry is dropped or the entire dictionary is deallocated. <br /> As in the OS X implementation, keys must therefore implement the <a rel="gsdoc" href="NSObject.html#protocol$(NSCopying)"><NSCopying></a> protocol. </p> <p> </p> <p> Objects of this class are immutable. For a mutable version, use the <a rel="gsdoc" href="#class$NSMutableDictionary">NSMutableDictionary</a> subclass. </p> <p> </p> <p> The basic functionality in <code>NSDictionary</code> is similar to that in Java's <code>HashMap</code>, and like that class it includes no locking code and is not thread-safe. If the contents will be modified and accessed from multiple threads you should enclose critical operations within locks (see <a rel="gsdoc" href="NSLock.html#class$NSLock">NSLock</a> ). </p> <p> </div> <b>Method summary</b> <ul> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary+dictionary">+dictionary</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary+dictionaryWithContentsOfFile$">+dictionaryWithContentsOfFile:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary+dictionaryWithContentsOfURL$">+dictionaryWithContentsOfURL:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary+dictionaryWithDictionary$">+dictionaryWithDictionary:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary+dictionaryWithObject$forKey$">+dictionaryWithObject:forKey:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary+dictionaryWithObjects$forKeys$">+dictionaryWithObjects:forKeys:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary+dictionaryWithObjects$forKeys$count$">+dictionaryWithObjects:forKeys:count:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary+dictionaryWithObjectsAndKeys$,...">+dictionaryWithObjectsAndKeys:,...</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-allKeys">-allKeys</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-allKeysForObject$">-allKeysForObject:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-allValues">-allValues</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-count">-count</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-description">-description</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-descriptionInStringsFileFormat">-descriptionInStringsFileFormat</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-descriptionWithLocale$">-descriptionWithLocale:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-descriptionWithLocale$indent$">-descriptionWithLocale:indent:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-enumerateKeysAndObjectsUsingBlock$">-enumerateKeysAndObjectsUsingBlock:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-enumerateKeysAndObjectsWithOptions$usingBlock$">-enumerateKeysAndObjectsWithOptions:usingBlock:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-getObjects$andKeys$">-getObjects:andKeys:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-init">-init</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-initWithContentsOfFile$">-initWithContentsOfFile:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-initWithContentsOfURL$">-initWithContentsOfURL:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-initWithDictionary$">-initWithDictionary:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-initWithDictionary$copyItems$">-initWithDictionary:copyItems:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-initWithObjects$forKeys$">-initWithObjects:forKeys:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-initWithObjects$forKeys$count$">-initWithObjects:forKeys:count:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-initWithObjectsAndKeys$,...">-initWithObjectsAndKeys:,...</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-isEqualToDictionary$">-isEqualToDictionary:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-keyEnumerator">-keyEnumerator</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-keysOfEntriesPassingTest$">-keysOfEntriesPassingTest:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-keysOfEntriesWithOptions$passingTest$">-keysOfEntriesWithOptions:passingTest:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-keysSortedByValueUsingSelector$">-keysSortedByValueUsingSelector:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-objectEnumerator">-objectEnumerator</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-objectForKey$">-objectForKey:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-objectForKeyedSubscript$">-objectForKeyedSubscript:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-objectsForKeys$notFoundMarker$">-objectsForKeys:notFoundMarker:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-valueForKey$">-valueForKey:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-writeToFile$atomically$">-writeToFile:atomically:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSDictionary-writeToURL$atomically$">-writeToURL:atomically:</a></li> </ul> <hr width="50%" align="left" /> <div class="method"> <h3><a name="method$NSDictionary+dictionary">dictionary </a></h3> + (instancetype) <b>dictionary</b>;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns a new autoreleased empty dictionary. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary+dictionaryWithContentsOfFile$">dictionaryWithContentsOfFile: </a></h3> + (instancetype) <b>dictionaryWithContentsOfFile:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)path;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns a dictionary using the file located at <var>path</var>. The file must be a property list containing a dictionary as its root object. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary+dictionaryWithContentsOfURL$">dictionaryWithContentsOfURL: </a></h3> + (instancetype) <b>dictionaryWithContentsOfURL:</b> (<a rel="gsdoc" href="NSURL.html#class$NSURL">NSURL</a>*)aURL;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.0.0</div> <br /> <div class="desc"> Returns a dictionary using the contents of <var>aURL</var>. The URL must be a property list containing a dictionary as its root object. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary+dictionaryWithDictionary$">dictionaryWithDictionary: </a></h3> + (instancetype) <b>dictionaryWithDictionary:</b> (<a rel="gsdoc" href="#class$NSDictionary">NSDictionary</a>*)otherDictionary;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns a newly created dictionary with the keys and objects of <var>otherDictionary</var>. (The keys and objects are not copied.) </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary+dictionaryWithObject$forKey$">dictionaryWithObject: forKey: </a></h3> + (instancetype) <b>dictionaryWithObject:</b> (id)object<b> forKey:</b> (id)key;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns a dictionary containing only one <var>object</var> which is associated with a <var>key</var>. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary+dictionaryWithObjects$forKeys$">dictionaryWithObjects: forKeys: </a></h3> + (instancetype) <b>dictionaryWithObjects:</b> (<a rel="gsdoc" href="NSArray.html#class$NSArray">NSArray</a>*)objects<b> forKeys:</b> (<a rel="gsdoc" href="NSArray.html#class$NSArray">NSArray</a>*)keys;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns a dictionary created using the given <var>objects</var> and <var>keys</var>. The two arrays must have the same length. The n th element of the <var>objects</var> array is associated with the n th element of the <var>keys</var> array. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary+dictionaryWithObjects$forKeys$count$">dictionaryWithObjects: forKeys: count: </a></h3> + (instancetype) <b>dictionaryWithObjects:</b> (const id[])objects<b> forKeys:</b> (const id<<a rel="gsdoc" href="NSObject.html#protocol$(NSCopying)">NSCopying</a>>[])keys<b> count:</b> (<a rel="gsdoc" href="TypesAndConstants.html#type$NSUInteger">NSUInteger</a>)count;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns a dictionary created using the given <var>objects</var> and <var>keys</var>. The two arrays must have the same size. The n th element of the <var>objects</var> array is associated with the n th element of the <var>keys</var> array. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary+dictionaryWithObjectsAndKeys$,...">dictionaryWithObjectsAndKeys: ,...</a></h3> + (instancetype) <b>dictionaryWithObjectsAndKeys:</b> (id)firstObject<b>,...</b>;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns a dictionary created using the list given as argument. The list is alternately composed of objects and keys and terminated by <code>nil</code>. Thus, the list's length must be even, followed by <code>nil</code>. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-allKeys">allKeys </a></h3> - (GS_GENERIC_CLASS(NSArray,KeyT)*) <b>allKeys</b>;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns an array containing all the dictionary's keys. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-allKeysForObject$">allKeysForObject: </a></h3> - (GS_GENERIC_CLASS(NSArray,KeyT)*) <b>allKeysForObject:</b> (id)anObject;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns an array containing all the dictionary's keys that are associated with <var>anObject</var>. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-allValues">allValues </a></h3> - (GS_GENERIC_CLASS(NSArray,ValT)*) <b>allValues</b>;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns an array containing all the dictionary's objects. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-count">count </a></h3> - (<a rel="gsdoc" href="TypesAndConstants.html#type$NSUInteger">NSUInteger</a>) <b>count</b>;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns an <strong>unsigned</strong> integer which is the number of elements stored in the dictionary. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-description">description </a></h3> - (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*) <b>description</b>;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns the result of invoking <a rel="gsdoc" href="#method$NSDictionary-descriptionWithLocale$indent$"> -descriptionWithLocale:indent: </a> with a <code>nil</code> locale and zero indent. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-descriptionInStringsFileFormat">descriptionInStringsFileFormat </a></h3> - (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*) <b>descriptionInStringsFileFormat</b>;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns the receiver as a text property list strings file format. <br /> See <a rel="gsdoc" href="NSString.html#method$NSString-propertyListFromStringsFileFormat">[NSString -propertyListFromStringsFileFormat]</a> for details. <br /> The order of the items is undefined. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-descriptionWithLocale$">descriptionWithLocale: </a></h3> - (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*) <b>descriptionWithLocale:</b> (id)locale;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns the result of invoking <a rel="gsdoc" href="#method$NSDictionary-descriptionWithLocale$indent$"> -descriptionWithLocale:indent: </a> with a zero indent. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-descriptionWithLocale$indent$">descriptionWithLocale: indent: </a></h3> - (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*) <b>descriptionWithLocale:</b> (id)locale<b> indent:</b> (<a rel="gsdoc" href="TypesAndConstants.html#type$NSUInteger">NSUInteger</a>)level;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns the receiver as a text property list in the traditional format. <br /> See <a rel="gsdoc" href="NSString.html#method$NSString-propertyList"> [NSString -propertyList] </a> for details. <br /> If <var>locale</var> is <code>nil</code>, no formatting is done, otherwise entries are formatted according to the <var>locale</var>, and indented according to <var>level</var>. <br /> Unless <var>locale</var> is <code>nil</code>, a <var>level</var> of zero indents items by four spaces, while a <var>level</var> of one indents them by a tab. <br /> If the keys in the dictionary respond to [NSObject -compare:] , the items are listed by key in ascending order. If not, the order in which the items are listed is undefined. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-enumerateKeysAndObjectsUsingBlock$">enumerateKeysAndObjectsUsingBlock: </a></h3> - (void) <b>enumerateKeysAndObjectsUsingBlock:</b> (GSKeysAndObjectsEnumeratorBlock)aBlock;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.6.0</div> <br /> <div class="desc"> <em>Description forthcoming.</em> </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-enumerateKeysAndObjectsWithOptions$usingBlock$">enumerateKeysAndObjectsWithOptions: usingBlock: </a></h3> - (void) <b>enumerateKeysAndObjectsWithOptions:</b> (<a rel="gsdoc" href="TypesAndConstants.html#type$NSEnumerationOptions">NSEnumerationOptions</a>)opts<b> usingBlock:</b> (GSKeysAndObjectsEnumeratorBlock)aBlock;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.6.0</div> <br /> <div class="desc"> <em>Description forthcoming.</em> </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-getObjects$andKeys$">getObjects: andKeys: </a></h3> - (void) <b>getObjects:</b> (__unsafe_unretained id[])objects<b> andKeys:</b> (__unsafe_unretained id<<a rel="gsdoc" href="NSObject.html#protocol$(NSCopying)">NSCopying</a>>[])keys;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> <em>Description forthcoming.</em> </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-init">init </a></h3> - (instancetype) <b>init</b>;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> </p> <p> In MacOS-X class clusters do not have designated initialisers, and there is a general rule that <a rel="gsdoc" href="#method$NSDictionary-init">-init</a> is treated as the designated initialiser of the class cluster, but that other intitialisers may not work s expected an would need to be individually overridden in any subclass. </p> <p> </p> <p> GNUstep tries to make it easier to subclass a class cluster, by making class clusters follow the same convention as normal classes, so the designated initialiser is the <em>richest</em> initialiser. This means that all other initialisers call the documented designated initialiser (which calls <a rel="gsdoc" href="#method$NSDictionary-init"> -init </a> only for MacOS-X compatibility), and anyone writing a subclass only needs to override that one initialiser in order to have all the other ones work. </p> <p> </p> <p> For MacOS-X compatibility, you may also need to override various other initialisers. Exactly which ones, you will need to determine by trial on a MacOS-X system... and may vary between releases of MacOS-X. So to be safe, on MacOS-X you probably need to re-implement <em>all</em> the class cluster initialisers you might use in conjunction with your subclass. </p> <p> </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-initWithContentsOfFile$">initWithContentsOfFile: </a></h3> - (instancetype) <b>initWithContentsOfFile:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)path;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> </p> <p> Initialises the dictionary with the contents of the specified file, which must contain a dictionary in property-list format. </p> <p> </p> <p> In GNUstep, the property-list format may be either the OpenStep format (ASCII data), or the MacOS-X format (UTF-8 XML data)... this method will recognise which it is. </p> <p> </p> <p> If there is a failure to load the file for any reason, the receiver will be released and the method will return <code>nil</code>. </p> <p> </p> <p> Works by invoking <a rel="gsdoc" href="NSString.html#method$NSString-initWithContentsOfFile$">[NSString -initWithContentsOfFile:]</a> and <a rel="gsdoc" href="NSString.html#method$NSString-propertyList">[NSString -propertyList]</a> then checking that the result is a dictionary. </p> <p> </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-initWithContentsOfURL$">initWithContentsOfURL: </a></h3> - (instancetype) <b>initWithContentsOfURL:</b> (<a rel="gsdoc" href="NSURL.html#class$NSURL">NSURL</a>*)aURL;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.0.0</div> <br /> <div class="desc"> </p> <p> Initialises the dictionary with the contents of the specified URL, which must contain a dictionary in property-list format. </p> <p> </p> <p> In GNUstep, the property-list format may be either the OpenStep format (ASCII data), or the MacOS-X format (UTF-8 XML data)... this method will recognise which it is. </p> <p> </p> <p> If there is a failure to load the URL for any reason, the receiver will be released and the method will return <code>nil</code>. </p> <p> </p> <p> Works by invoking <a rel="gsdoc" href="NSString.html#method$NSString-initWithContentsOfURL$">[NSString -initWithContentsOfURL:]</a> and <a rel="gsdoc" href="NSString.html#method$NSString-propertyList">[NSString -propertyList]</a> then checking that the result is a dictionary. </p> <p> </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-initWithDictionary$">initWithDictionary: </a></h3> - (instancetype) <b>initWithDictionary:</b> (<a rel="gsdoc" href="#class$NSDictionary">NSDictionary</a>*)otherDictionary;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Initializes with the keys and objects of <var>otherDictionary</var>. (The keys and objects are not copied.) </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-initWithDictionary$copyItems$">initWithDictionary: copyItems: </a></h3> - (id) <b>initWithDictionary:</b> (<a rel="gsdoc" href="#class$NSDictionary">NSDictionary</a>*)other<b> copyItems:</b> (BOOL)shouldCopy;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Initialise dictionary with the keys and values of otherDictionary. If the <var>shouldCopy</var> flag is <code>YES</code> then the values are copied into the newly initialised dictionary, otherwise they are simply retained, on the assumption that it is safe to retain the keys from another dictionary since that <var>other</var> dictionary mwill have copied the keys originally to ensure that they are immutable. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-initWithObjects$forKeys$">initWithObjects: forKeys: </a></h3> - (id) <b>initWithObjects:</b> (<a rel="gsdoc" href="NSArray.html#class$NSArray">NSArray</a>*)objects<b> forKeys:</b> (<a rel="gsdoc" href="NSArray.html#class$NSArray">NSArray</a>*)keys;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Initialises a dictionary created using the given <var>objects</var> and <var>keys</var>. The two arrays must have the same size. The n th element of the <var>objects</var> array is associated with the n th element of the <var>keys</var> array. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-initWithObjects$forKeys$count$">initWithObjects: forKeys: count: </a></h3> - (id) <b>initWithObjects:</b> (const id[])objects<b> forKeys:</b> (const id<<a rel="gsdoc" href="NSObject.html#protocol$(NSCopying)">NSCopying</a>>[])keys<b> count:</b> (<a rel="gsdoc" href="TypesAndConstants.html#type$NSUInteger">NSUInteger</a>)count;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> This is a designated initialiser for the class.<br /> Subclasses <strong>must</strong> override this method.<br /> <div class="desc"> Initializes contents to the given <var>objects</var> and <var>keys</var>. The two arrays must have the same size. The n th element of the <var>objects</var> array is associated with the n th element of the <var>keys</var> array. <br /> Calls <a rel="gsdoc" href="#method$NSDictionary-init"> -init </a> (which does nothing but maintain MacOS-X compatibility), and needs to be re-implemented in subclasses in order to have all other initialisers work. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-initWithObjectsAndKeys$,...">initWithObjectsAndKeys: ,...</a></h3> - (id) <b>initWithObjectsAndKeys:</b> (id)firstObject<b>,...</b>;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Initialises a dictionary created using the list given as argument. The list is alternately composed of objects and keys and terminated by <code>nil</code>. Thus, the list's length must be even, followed by <code>nil</code>. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-isEqualToDictionary$">isEqualToDictionary: </a></h3> - (BOOL) <b>isEqualToDictionary:</b> (<a rel="gsdoc" href="#class$NSDictionary">NSDictionary</a>*)other;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Two dictionaries are equal if they each hold the same number of entries, each key in one <code>isEqual</code> to a key in the <var>other</var>, and, for a given key, the corresponding value objects also satisfy <code>isEqual</code>. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-keyEnumerator">keyEnumerator </a></h3> - (GS_GENERIC_CLASS(NSEnumerator,KeyT)*) <b>keyEnumerator</b>;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Return an enumerator object containing all the keys of the dictionary. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-keysOfEntriesPassingTest$">keysOfEntriesPassingTest: </a></h3> - (GS_GENERIC_CLASS(NSSet,KeyT)*) <b>keysOfEntriesPassingTest:</b> (GSKeysAndObjectsPredicateBlock)aPredicate;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.6.0</div> <br /> <div class="desc"> <em>Description forthcoming.</em> </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-keysOfEntriesWithOptions$passingTest$">keysOfEntriesWithOptions: passingTest: </a></h3> - (GS_GENERIC_CLASS(NSSet,KeyT)*) <b>keysOfEntriesWithOptions:</b> (<a rel="gsdoc" href="TypesAndConstants.html#type$NSEnumerationOptions">NSEnumerationOptions</a>)opts<b> passingTest:</b> (GSKeysAndObjectsPredicateBlock)aPredicate;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.6.0</div> <br /> <div class="desc"> <em>Description forthcoming.</em> </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-keysSortedByValueUsingSelector$">keysSortedByValueUsingSelector: </a></h3> - (GS_GENERIC_CLASS(NSArray,ValT)*) <b>keysSortedByValueUsingSelector:</b> (SEL)comp;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns ordered array of the keys sorted according to the values they correspond to. To sort the values, a message with selector <var>comp</var> is send to each value with another value as argument, as in <code>[a comp: b]</code>. The <var>comp</var> method should return <code>NSOrderedSame</code>, <code>NSOrderedAscending</code>, or <code>NSOrderedDescending</code> as appropriate. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-objectEnumerator">objectEnumerator </a></h3> - (GS_GENERIC_CLASS(NSEnumerator,ValT)*) <b>objectEnumerator</b>;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Return an enumerator object containing all the objects of the dictionary. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-objectForKey$">objectForKey: </a></h3> - (GS_GENERIC_TYPE(ValT)) <b>objectForKey:</b> (id)aKey;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns the object in the dictionary corresponding to <var>aKey</var>, or <code>nil</code> if the key is not present. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-objectForKeyedSubscript$">objectForKeyedSubscript: </a></h3> - (GS_GENERIC_TYPE(ValT)) <b>objectForKeyedSubscript:</b> (id)aKey;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Method called by array subscripting. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-objectsForKeys$notFoundMarker$">objectsForKeys: notFoundMarker: </a></h3> - (GS_GENERIC_CLASS(NSArray,ValT)*) <b>objectsForKeys:</b> (<a rel="gsdoc" href="NSArray.html#class$NSArray">NSArray</a>*)keys<b> notFoundMarker:</b> (id)marker;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Multiple version of <a rel="gsdoc" href="#method$NSDictionary-objectForKey$"> -objectForKey: </a> . Objects for each key in <var>keys</var> are looked up and placed into return array in same order. For each key that has no corresponding value in this dictionary, <var>marker</var> is put into the array in its place. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-valueForKey$">valueForKey: </a></h3> - (GS_GENERIC_TYPE(ValT)) <b>valueForKey:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)key;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.0.0</div> <br /> <div class="desc"> Default implementation for this class is to return the value stored in the dictionary under the specified <var>key</var>, or <code>nil</code> if there is no value. <br /> However, if the <var>key</var> begins with '@' that character is stripped from it and the superclass implementation of the method is used. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-writeToFile$atomically$">writeToFile: atomically: </a></h3> - (BOOL) <b>writeToFile:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)path<b> atomically:</b> (BOOL)useAuxiliaryFile;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> </p> <p> Writes the contents of the dictionary to the file specified by <var>path</var>. The file contents will be in property-list format... under GNUstep this is either OpenStep style (ASCII characters using \U hexadecimal escape sequences for unicode), or MacOS-X style (XML in the UTF8 character set). </p> <p> </p> <p> If the <var>useAuxiliaryFile</var> flag is <code>YES</code>, the file write operation is atomic... the data is written to a temporary file, which is then renamed to the actual file name. </p> <p> </p> <p> If the conversion of data into the correct property-list format fails or the write operation fails, the method returns <code>NO</code>, otherwise it returns <code>YES</code>. </p> <p> </p> <p> NB. The fact that the file is in property-list format does not necessarily mean that it can be used to reconstruct the dictionary using the <a rel="gsdoc" href="#method$NSDictionary-initWithContentsOfFile$"> -initWithContentsOfFile: </a> method. If the original dictionary contains non-property-list objects, the descriptions of those objects will have been written, and reading in the file as a property-list will result in a new dictionary containing the string descriptions. </p> <p> </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSDictionary-writeToURL$atomically$">writeToURL: atomically: </a></h3> - (BOOL) <b>writeToURL:</b> (<a rel="gsdoc" href="NSURL.html#class$NSURL">NSURL</a>*)url<b> atomically:</b> (BOOL)useAuxiliaryFile;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.0.0</div> <br /> <div class="desc"> </p> <p> Writes the contents of the dictionary to the specified <var>url</var>. This functions just like <a rel="gsdoc" href="#method$NSDictionary-writeToFile$atomically$"> -writeToFile:atomically: </a> except that the output may be written to any URL, not just a local file. </p> <p> </div> <hr width="25%" align="left" /> </div> <h1><a name="002000000000"> Software documentation for the NSMutableDictionary class </a></h1> <h2><a name="class$NSMutableDictionary">NSMutableDictionary</a> : <a rel="gsdoc" href="#class$NSDictionary">NSDictionary</a></h2> <blockquote class="declared"> <dl> <dt><b>Declared in:</b></dt> <dd>Foundation/NSDictionary.h</dd> </dl> </blockquote> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Mutable version of <a rel="gsdoc" href="#class$NSDictionary">NSDictionary</a> . </div> <b>Method summary</b> <ul> <li><a rel="gsdoc" href="NSDictionary.html#method$NSMutableDictionary+dictionaryWithCapacity$">+dictionaryWithCapacity:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSMutableDictionary-addEntriesFromDictionary$">-addEntriesFromDictionary:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSMutableDictionary-initWithCapacity$">-initWithCapacity:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSMutableDictionary-removeAllObjects">-removeAllObjects</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSMutableDictionary-removeObjectForKey$">-removeObjectForKey:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSMutableDictionary-removeObjectsForKeys$">-removeObjectsForKeys:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSMutableDictionary-setDictionary$">-setDictionary:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSMutableDictionary-setObject$forKey$">-setObject:forKey:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSMutableDictionary-setObject$forKeyedSubscript$">-setObject:forKeyedSubscript:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSMutableDictionary-setValue$forKey$">-setValue:forKey:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSMutableDictionary-takeStoredValue$forKey$">-takeStoredValue:forKey:</a></li> <li><a rel="gsdoc" href="NSDictionary.html#method$NSMutableDictionary-takeValue$forKey$">-takeValue:forKey:</a></li> </ul> <hr width="50%" align="left" /> <div class="method"> <h3><a name="method$NSMutableDictionary+dictionaryWithCapacity$">dictionaryWithCapacity: </a></h3> + (instancetype) <b>dictionaryWithCapacity:</b> (<a rel="gsdoc" href="TypesAndConstants.html#type$NSUInteger">NSUInteger</a>)numItems;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns an empty dictionary with memory preallocated for given number of entries. Although memory space will be grown as needed when entries are added, this can avoid the reallocate-and-copy process if the size of the ultimate contents is known in advance. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSMutableDictionary-addEntriesFromDictionary$">addEntriesFromDictionary: </a></h3> - (void) <b>addEntriesFromDictionary:</b> (<a rel="gsdoc" href="#class$NSDictionary">NSDictionary</a>*)otherDictionary;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Merges information from <var>otherDictionary</var> into the receiver. If a key exists in both dictionaries, the value from <var>otherDictionary</var> replaces that which was originally in the receiver. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSMutableDictionary-initWithCapacity$">initWithCapacity: </a></h3> - (instancetype) <b>initWithCapacity:</b> (<a rel="gsdoc" href="TypesAndConstants.html#type$NSUInteger">NSUInteger</a>)numItems;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> This is a designated initialiser for the class.<br /> Subclasses <strong>must</strong> override this method.<br /> <div class="desc"> Initializes an empty dictionary with memory preallocated for given number of entries. Although memory space will be grown as needed when entries are added, this can avoid the reallocate-and-copy process if the size of the ultimate contents is known in advance. <br /> Calls <a rel="gsdoc" href="#method$NSDictionary-init">-init</a> (which does nothing but maintain MacOS-X compatibility), and needs to be re-implemented in subclasses in order to have all other initialisers work. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSMutableDictionary-removeAllObjects">removeAllObjects </a></h3> - (void) <b>removeAllObjects</b>;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Clears out this dictionary by removing all entries. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSMutableDictionary-removeObjectForKey$">removeObjectForKey: </a></h3> - (void) <b>removeObjectForKey:</b> (id)aKey;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Removes the object with the specified key from the receiver. This method is primitive. <br /> Remove key-value mapping for given key <var>aKey</var>. No error if there is no mapping for the key. A warning will be generated if <var>aKey</var> is <code>nil</code>. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSMutableDictionary-removeObjectsForKeys$">removeObjectsForKeys: </a></h3> - (void) <b>removeObjectsForKeys:</b> (<a rel="gsdoc" href="NSArray.html#class$NSArray">NSArray</a>*)keyArray;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Remove entries specified by the given <var>keyArray</var>. No error is generated if no mapping exists for a key or one is <code>nil</code> , although a console warning is produced in the latter case. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSMutableDictionary-setDictionary$">setDictionary: </a></h3> - (void) <b>setDictionary:</b> (<a rel="gsdoc" href="#class$NSDictionary">NSDictionary</a>*)otherDictionary;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Remove all entries, then add all entries from <var>otherDictionary</var>. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSMutableDictionary-setObject$forKey$">setObject: forKey: </a></h3> - (void) <b>setObject:</b> (id)anObject<b> forKey:</b> (id)aKey;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Adds entry for <var>aKey</var>, mapping to <var>anObject</var>. If either is <code>nil</code>, an exception is raised. If <var>aKey</var> already in dictionary, the value it maps to is silently replaced. The value <var>anObject</var> is retained, but <var>aKey</var> is copied (because a dictionary key must be immutable) and must therefore implement the <a rel="gsdoc" href="NSObject.html#protocol$(NSCopying)"><NSCopying></a> protocol.) </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSMutableDictionary-setObject$forKeyedSubscript$">setObject: forKeyedSubscript: </a></h3> - (void) <b>setObject:</b> (id)anObject<b> forKeyedSubscript:</b> (id)aKey;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Method called by array subscripting. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSMutableDictionary-setValue$forKey$">setValue: forKey: </a></h3> - (void) <b>setValue:</b> (id)value<b> forKey:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)key;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.0.0</div> <br /> <div class="desc"> Default implementation for this class is equivalent to the <a rel="gsdoc" href="#method$NSMutableDictionary-setObject$forKey$"> -setObject:forKey: </a> method unless <var>value</var> is <code>nil</code>, in which case it is equivalent to <a rel="gsdoc" href="#method$NSMutableDictionary-removeObjectForKey$"> -removeObjectForKey: </a> </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSMutableDictionary-takeStoredValue$forKey$">takeStoredValue: forKey: </a></h3> - (void) <b>takeStoredValue:</b> (id)value<b> forKey:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)key;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.0.0</div> <br /> <div class="desc"> Default implementation for this class is equivalent to the <a rel="gsdoc" href="#method$NSMutableDictionary-setObject$forKey$"> -setObject:forKey: </a> method unless <var>value</var> is <code>nil</code>, in which case it is equivalent to <a rel="gsdoc" href="#method$NSMutableDictionary-removeObjectForKey$"> -removeObjectForKey: </a> </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSMutableDictionary-takeValue$forKey$">takeValue: forKey: </a></h3> - (void) <b>takeValue:</b> (id)value<b> forKey:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)key;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.0.0</div> <br /> <div class="desc"> Default implementation for this class is equivalent to the <a rel="gsdoc" href="#method$NSMutableDictionary-setObject$forKey$"> -setObject:forKey: </a> method unless <var>value</var> is <code>nil</code>, in which case it is equivalent to <a rel="gsdoc" href="#method$NSMutableDictionary-removeObjectForKey$"> -removeObjectForKey: </a> </div> <hr width="25%" align="left" /> </div> <br /> <a href="Base.html">Up</a> </font> </body> </html>