Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
2461 lines (1329 sloc) 432 KB
<body>
<a name="//apple_ref/doc/uid/20000154" title="NSString"></a>
<div id="adcHeader" class="hideOnPrint hideInXcode"></div>
<div id="header">
...
</div>
<div id="tocContainer" class="isShowingTOC">
...
</div>
<div id="contents" class="isShowingTOC">
<a id="top" name="top"></a>
<a id="INDEX" href="../index.html" style="display:none;"></a>
<a name="//apple_ref/occ/cl/NSString" title="NSString"></a><a name="//apple_ref/doc/c_ref/NSString" title="NSString"></a><a name="//apple_ref/doc/uid/20000154-CJBIAEDJ" title="NSString"></a><br /><h1 id="pageTitle">NSString Class Reference</h1><div class="spec_sheet_info_box"><table cellspacing="0" class="specbox"><tr><td scope="row"><strong><span style="white-space: nowrap;">Inherits from</span></strong></td><td><div style="margin-bottom:1px"><a href="../../NSObject_Class/Reference/Reference.html#//apple_ref/occ/cl/NSObject" target="_top">NSObject</a></div></td></tr><tr><td scope="row"><strong><span class="noWrap">Conforms to</span></strong></td><td><div style="margin-bottom:1px"><span class="content_text"><a href="../../../Protocols/NSCoding_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSCoding" target="_top">NSCoding</a></span><br/><span class="content_text"><a href="../../../Protocols/NSCopying_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSCopying" target="_top">NSCopying</a></span><br/><span class="content_text"><a href="../../../Protocols/NSMutableCopying_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSMutableCopying" target="_top">NSMutableCopying</a></span><br/><span class="content_text"><a href="../../../Protocols/NSObject_Protocol/Reference/NSObject.html#//apple_ref/occ/intf/NSObject" target="_top">NSObject (NSObject)</a></span><br/></div></td></tr><tr><td scope="row"><strong><span style="white-space: nowrap;">Framework</span></strong></td><td><div style="margin-bottom:1px">/System/Library/Frameworks/<a href="../../../ObjC_classic/index.html#//apple_ref/doc/uid/20001091" target="_top">Foundation.framework</a></div></td></tr><tr><td scope="row"><strong>Availability</strong></td><td><div style="margin-bottom:1px"><div>Available in iPhone OS 2.0 and later.</div></div></td></tr><tr><td scope="row"><strong><span style="white-space: nowrap;">Declared in</span></strong></td><td><div style="margin-bottom:1px"><span class="content_text">NSPathUtilities.h</span><br/><span class="content_text">NSString.h</span><br/><span class="content_text">NSURL.h</span><br/></div></td></tr><tr><td scope="row"><strong><span class="noWrap">Companion guides</span></strong></td><td><div style="margin-bottom:1px"><span class="content_text"><a href="../../../../../Conceptual/Strings/index.html#//apple_ref/doc/uid/10000035i" target="_top">String Programming Guide for Cocoa</a></span><br/><span class="content_text"><a href="../../../../../Conceptual/PropertyLists/index.html#//apple_ref/doc/uid/10000048i" target="_top">Property List Programming Guide</a></span><br/></div></td></tr><tr><td scope="row"><strong><span style="white-space: nowrap;">Related sample code</span></strong></td><td><div style="margin-bottom:1px"><div><span class="content_text"><a href="../../../../../../../samplecode/BonjourWeb/index.html#//apple_ref/doc/uid/DTS40007415" target="_top">BonjourWeb</a></span></div><div><span class="content_text"><a href="./https:/devpubsbuild2.apple.com/Messier/Releases/WildcatDevCenter/samplecode/SimpleFTPSample/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009243">SimpleFTPSample</a></span></div><div><span class="content_text"><a href="../../../../../../../samplecode/SimpleURLConnections/index.html#//apple_ref/doc/uid/DTS40009245" target="_top">SimpleURLConnections</a></span></div><div><span class="content_text"><a href="../../../../../../../samplecode/TableViewSuite/index.html#//apple_ref/doc/uid/DTS40007318" target="_top">TableViewSuite</a></span></div><div><span class="content_text"><a href="../../../../../../../samplecode/TheElements/index.html#//apple_ref/doc/uid/DTS40007419" target="_top">TheElements</a></span></div></div></td></tr></table></div><br/>
<div id="Overview_section" class="zClassDescription"><a name="//apple_ref/doc/uid/20000154-10850" title="Overview"></a><h2 class="jump zClassDescription_Name">Overview</h2><div class="importantbox clear"><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_4" title="Important:"></a><p><strong>Important:</strong>&nbsp;This is a preliminary document for an API or technology in development. Although this document has been reviewed for technical accuracy, it is not final. Apple is supplying this information to help you plan for the adoption of the technologies and programming interfaces described herein. This information is subject to change, and software implemented according to this document should be tested with final operating system software and final documentation. Newer versions of this document may be provided with future seeds of the API or technology.</p><p></p></div>
<p class="abstract">The <code>NSString</code> class declares the programmatic interface for an object that manages immutable strings. (An immutable string is a text string that is defined when it is created and subsequently cannot be changed. <code>NSString</code> is implemented to represent an array of Unicode characters (in other words, a text string).</p>
<p>The mutable subclass of <code>NSString</code> is <code><a href="../../NSMutableString_Class/Reference/Reference.html#//apple_ref/occ/cl/NSMutableString" target="_top">NSMutableString</a></code>.</p>
<p>The <code>NSString</code> class has two primitive methods—<code><a href="NSString.html#//apple_ref/occ/instm/NSString/length">length</a></code> and <code><a href="NSString.html#//apple_ref/occ/instm/NSString/characterAtIndex:">characterAtIndex:</a></code>—that provide the basis for all other methods in its interface. The <code><a href="NSString.html#//apple_ref/occ/instm/NSString/length">length</a></code> method returns the total number of Unicode characters in the string. <code><a href="NSString.html#//apple_ref/occ/instm/NSString/characterAtIndex:">characterAtIndex:</a></code> gives access to each character in the string by index, with index values starting at <code>0</code>.</p>
<p><code>NSString</code> declares methods for finding and comparing strings. It also declares methods for reading numeric values from strings, for combining strings in various ways, and for converting a string to different forms (such as encoding and case changes).</p>
<p>The Application Kit also uses <code><!--a target="_top" -->NSParagraphStyle<!--/a--></code> and its subclass <code><!--a target="_top" -->NSMutableParagraphStyle<!--/a--></code> to encapsulate the paragraph or ruler attributes used by the <code>NSAttributedString</code> classes. Additionally, methods to support string drawing are described in <span class="content_text"><!--a target="_top" -->NSString Application Kit Additions Reference<!--/a--></span>, found in the Application Kit.</p>
<p><code>NSString</code> is “toll-free bridged” with its Core Foundation counterpart, CFString (see <code><a href="../../../../../../CoreFoundation/Reference/CFStringRef/Reference/reference.html#//apple_ref/c/tdef/CFStringRef" target="_top">CFStringRef</a></code>). This means that the Core Foundation type is interchangeable in function or method calls with the bridged Foundation object. Therefore, in a method where you see an <code>NSString *</code> parameter, you can pass a <code>CFStringRef</code>, and in a function where you see a <code>CFStringRef</code> parameter, you can pass an <code>NSString</code> instance (you cast one type to the other to suppress compiler warnings). This also applies to your concrete subclasses of <code>NSString</code>. See <span class="content_text"><!--a target="_top" -->Interchangeable Data Types<!--/a--></span> for more information on toll-free bridging.</p>
<a name="//apple_ref/doc/uid/20000154-385606" title="String Objects"></a><h3>String Objects</h3>
<p><code>NSString</code> objects represent character strings in frameworks. Representing strings as objects allows you to use strings wherever you use other objects. It also provides the benefits of encapsulation, so that string objects can use whatever encoding and storage are needed for efficiency while simply appearing as arrays of characters. The cluster’s two public classes, <code>NSString</code> and <code>NSMutableString</code>, declare the programmatic interface for non-editable and editable strings, respectively.</p><div class="notebox clear"><a name="//apple_ref/doc/uid/20000154-SW9" title="Note"></a><strong>Note:</strong>&nbsp;An immutable string is a text string that is defined when it is created and subsequently cannot be changed. An immutable string is implemented as an array of Unicode characters (in other words, a text string). To create and manage an immutable string, use the <code>NSString</code> class. To construct and manage a string that can be changed after it has been created, use <code><a href="../../NSMutableString_Class/Reference/Reference.html#//apple_ref/occ/cl/NSMutableString" target="_top">NSMutableString</a></code>.</p><p></div>
<p>The objects you create using <code>NSString</code> and <code>NSMutableString</code> are referred to as string objects (or, when no confusion will result, merely as strings). The term C string refers to the standard <code>char *</code> type. Because of the nature of class clusters, string objects aren’t actual instances of the <code>NSString</code> or <code>NSMutableString</code> classes but of one of their private subclasses. Although a string object’s class is private, its interface is public, as declared by these abstract superclasses, <code>NSString</code> and <code>NSMutableString</code>. The string classes adopt the <code><a href="../../../Protocols/NSCopying_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSCopying" target="_top">NSCopying</a></code> and <code><a href="../../../Protocols/NSMutableCopying_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSMutableCopying" target="_top">NSMutableCopying</a></code> protocols, making it convenient to convert a string of one type to the other.</p><a name="//apple_ref/doc/uid/20000154-SW83" title="Understanding characters"></a><h3 class="jump section3">Understanding characters</h3>
<p>A string object presents itself as an array of Unicode characters (Unicode is a registered trademark of Unicode, Inc.). You can determine how many characters a string object contains with the <code><a href="NSString.html#//apple_ref/occ/instm/NSString/length">length</a></code> method and can retrieve a specific character with the <code><a href="NSString.html#//apple_ref/occ/instm/NSString/characterAtIndex:">characterAtIndex:</a></code> method. These two “primitive” methods provide basic access to a string object.</p><p>Most use of strings, however, is at a higher level, with the strings being treated as single entities: You compare strings against one another, search them for substrings, combine them into new strings, and so on. If you need to access string objects character by character, you must understand the Unicode character encoding, specifically issues related to composed character sequences. For details see <em>The Unicode Standard, Version 4.0</em> (The Unicode Consortium, Boston: Addison-Wesley, 2003, ISBN 0-321-18578-1) and the Unicode Consortium web site: <span class="content_text"><a href="http://www.unicode.org/" class="urlLink">http://www.unicode.org/</a></span>. See also <span class="content_text"><a href="../../../../../Conceptual/Strings/Articles/stringsClusters.html#//apple_ref/doc/uid/TP40008025" target="_top">Characters and Grapheme Clusters</a></span> in <em><a href="../../../../../Conceptual/Strings/index.html#//apple_ref/doc/uid/10000035i" target="_top">String Programming Guide for Cocoa</a></em>.</p><a name="//apple_ref/doc/uid/20000154-SW84" title="Interpreting UTF-16-encoded data"></a><h3 class="jump section3">Interpreting UTF-16-encoded data</h3><p>When creating an <code>NSString</code> object from a UTF-16-encoded string (or a byte stream interpreted as UTF-16), if the byte order is not otherwise specified, <code>NSString</code> assumes that the UTF-16 characters are big-endian, unless there is a BOM (byte-order mark), in which case the BOM dictates the byte order. When creating an <code>NSString</code> object from an array of Unicode characters, the returned string is always native-endian, since the array always contains Unicode characters in native byte order.</p><a name="//apple_ref/doc/uid/20000154-SW85" title="Distributed objects"></a><h3 class="jump section3">Distributed objects</h3><p>Over distributed-object connections, mutable string objects are passed by-reference and immutable string objects are passed by-copy.</p>
<a name="//apple_ref/doc/uid/20000154-397865" title="Subclassing Notes"></a><h3>Subclassing Notes</h3>
<p class="spaceabove"> It is possible to subclass <code>NSString</code> (and <code>NSMutableString</code>), but doing so requires providing storage facilities for the string (which is not inherited by subclasses) and implementing two primitive methods. The abstract <code>NSString</code> and <code>NSMutableString</code> classes are the public interface of a class cluster consisting mostly of private, concrete classes that create and return a string object appropriate for a given situation. Making your own concrete subclass of this cluster imposes certain requirements (discussed in <span class="content_text"><a href="NSString.html#//apple_ref/doc/uid/20000154-397909">“Methods to Override”</a></span>). </p>
<p class="spaceabove"> Make sure your reasons for subclassing <code>NSString</code> are valid. Instances of your subclass should represent a string and not something else. Thus the only attributes the subclass should have are the length of the character buffer it’s managing and access to individual characters in the buffer. Valid reasons for making a subclass of <code>NSString</code> include providing a different backing store (perhaps for better performance) or implementing some aspect of object behavior differently, such as memory management. If your purpose is to add non-essential attributes or metadata to your subclass of <code>NSString</code>, a better alternative would be object composition (see <span class="content_text"><a href="NSString.html#//apple_ref/doc/uid/20000154-397934">“Alternatives to Subclassing”</a></span>). Cocoa already provides an example of this with the <code><a href="../../NSAttributedString_Class/Reference/Reference.html#//apple_ref/occ/cl/NSAttributedString" target="_top">NSAttributedString</a></code> class.</p>
<a name="//apple_ref/doc/uid/20000154-397909" title="Methods to Override"></a><a name="//apple_ref/doc/uid/20000154-CJBECBBA" title="Methods to Override"></a><h4>Methods to Override</h4>
<p class="spaceabove">Any subclass of <code>NSString</code> <em>must</em> override the primitive instance methods <code><a href="NSString.html#//apple_ref/occ/instm/NSString/length">length</a></code> and <code><a href="NSString.html#//apple_ref/occ/instm/NSString/characterAtIndex:">characterAtIndex:</a></code>. These methods must operate on the backing store that you provide for the characters of the string. For this backing store you can use a static array, a dynamically allocated buffer, a standard <code>NSString</code> object, or some other data type or mechanism. You may also choose to override, partially or fully, any other <code>NSString</code> method for which you want to provide an alternative implementation. For example, for better performance it is recommended that you override <code><a href="NSString.html#//apple_ref/occ/instm/NSString/getCharacters:range:">getCharacters:range:</a></code> and give it a faster implementation.</p>
<p class="spaceabove">You might want to implement an initializer for your subclass that is suited to the backing store that the subclass is managing. The <code>NSString</code> class does not have a designated initializer, so your initializer need only invoke the <code><a href="../../NSObject_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/init" target="_top">init</a></code> method of <code>super</code>. The <code>NSString</code> class adopts the <code><a href="../../../Protocols/NSCopying_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSCopying" target="_top">NSCopying</a></code>, <code><a href="../../../Protocols/NSMutableCopying_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSMutableCopying" target="_top">NSMutableCopying</a></code>, and <code><a href="../../../Protocols/NSCoding_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSCoding" target="_top">NSCoding</a></code> protocols; if you want instances of your own custom subclass created from copying or coding, override the methods in these protocols.</p>
<p class="spaceabove">Note that you shouldn’t override the <code><a href="NSString.html#//apple_ref/occ/instm/NSString/hash">hash</a></code> method.</p>
<a name="//apple_ref/doc/uid/20000154-397934" title="Alternatives to Subclassing"></a><a name="//apple_ref/doc/uid/20000154-CJBGGEDJ" title="Alternatives to Subclassing"></a><h4>Alternatives to Subclassing</h4>
<p class="spaceabove">Often a better and easier alternative to making a subclass of <code>NSString</code>—or of any other abstract, public class of a class cluster, for that matter—is object composition. This is especially the case when your intent is to add to the subclass metadata or some other attribute that is not essential to a string object. In object composition, you would have an <code>NSString</code> object as one instance variable of your custom class (typically a subclass of <code>NSObject</code>) and one or more instance variables that store the metadata that you want for the custom object. Then just design your subclass interface to include accessor methods for the embedded string object and the metadata.</p>
<p class="spaceabove">If the behavior you want to add supplements that of the existing class, you could write a category on <code>NSString</code>. Keep in mind, however, that this category will be in effect for all instances of <code>NSString</code> that you use, and this might have unintended consequences.</p></div>
<a name="//apple_ref/doc/uid/20000154-962506" title="Adopted Protocols"></a><h2 class="jump">Adopted Protocols</h2>
<a name="//apple_ref/doc/uid/20000154-SW10" title="NSCoding"></a><div class="content_text"><a href="../../../Protocols/NSCoding_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSCoding" target="_top">NSCoding</a></div>
<ul class="simple"><li><p><code><a href="../../../Protocols/NSCoding_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/NSCoding/encodeWithCoder:" target="_top">encodeWithCoder:</a></code></p></li>
<li><p><code><a href="../../../Protocols/NSCoding_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/NSCoding/initWithCoder:" target="_top">initWithCoder:</a></code></p></li></ul>
<a name="//apple_ref/doc/uid/20000154-SW11" title="NSCopying"></a><div class="content_text"><a href="../../../Protocols/NSCopying_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSCopying" target="_top">NSCopying</a></div>
<ul class="simple"><li><p><code><a href="../../../Protocols/NSCopying_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/NSCopying/copyWithZone:" target="_top">copyWithZone:</a></code></p></li></ul>
<a name="//apple_ref/doc/uid/20000154-SW12" title="NSMutableCopying"></a><div class="content_text"><a href="../../../Protocols/NSMutableCopying_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSMutableCopying" target="_top">NSMutableCopying</a></div>
<ul class="simple"><li><p><code><a href="../../../Protocols/NSMutableCopying_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/NSMutableCopying/mutableCopyWithZone:" target="_top">mutableCopyWithZone:</a></code></p></li></ul>
<div id="Tasks_section" class="zMethodsByTask"><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_1" title="Tasks"></a><h2 class="jump zMethodsByTask_Name">Tasks</h2>
<a name="//apple_ref/doc/uid/20000154-SW13" title="Creating and Initializing Strings"></a>
<h3 class="tasks">Creating and Initializing Strings</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/clm/NSString/string">+&#xA0;string</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an empty string.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/init">&#8211;&#xA0;init</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an initialized <code>NSString</code> object that contains no characters.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithBytes:length:encoding:">&#8211;&#xA0;initWithBytes:length:encoding:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an initialized <code>NSString</code> object containing a given number of bytes from a given buffer of bytes interpreted in a given encoding.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithBytesNoCopy:length:encoding:freeWhenDone:">&#8211;&#xA0;initWithBytesNoCopy:length:encoding:freeWhenDone:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an initialized <code>NSString</code> object that contains a given number of bytes from a given buffer of bytes interpreted in a given encoding, and optionally frees the buffer.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithCharacters:length:">&#8211;&#xA0;initWithCharacters:length:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an initialized <code>NSString</code> object that contains a given number of characters from a given C array of Unicode characters.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithCharactersNoCopy:length:freeWhenDone:">&#8211;&#xA0;initWithCharactersNoCopy:length:freeWhenDone:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an initialized <code>NSString</code> object that contains a given number of characters from a given C array of Unicode characters.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithString:">&#8211;&#xA0;initWithString:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <code>NSString</code> object initialized by copying the characters from another given string.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithCString:encoding:">&#8211;&#xA0;initWithCString:encoding:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <code>NSString</code> object initialized using the characters in a given C array, interpreted according to a given encoding. ' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithUTF8String:">&#8211;&#xA0;initWithUTF8String:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <code>NSString</code> object initialized by copying the characters a given C array of UTF8-encoded bytes.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithFormat:">&#8211;&#xA0;initWithFormat:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <em>NSString</em> object initialized by using a given format string as a template into which the remaining argument values are substituted.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithFormat:arguments:">&#8211;&#xA0;initWithFormat:arguments:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <em>NSString</em> object initialized by using a given format string as a template into which the remaining argument values are substituted according to the user’s default locale.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithFormat:locale:">&#8211;&#xA0;initWithFormat:locale:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <em>NSString</em> object initialized by using a given format string as a template into which the remaining argument values are substituted according to given locale information.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithFormat:locale:arguments:">&#8211;&#xA0;initWithFormat:locale:arguments:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <em>NSString</em> object initialized by using a given format string as a template into which the remaining argument values are substituted according to given locale information.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithData:encoding:">&#8211;&#xA0;initWithData:encoding:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <code>NSString</code> object initialized by converting given data into Unicode characters using a given encoding.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithFormat:">+&#xA0;stringWithFormat:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string created by using a given format string as a template into which the remaining argument values are substituted.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/clm/NSString/localizedStringWithFormat:">+&#xA0;localizedStringWithFormat:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string created by using a given format string as a template into which the remaining argument values are substituted according to the user&#8217;s default locale.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithCharacters:length:">+&#xA0;stringWithCharacters:length:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string containing a given number of characters taken from a given C array of Unicode characters.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithString:">+&#xA0;stringWithString:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string created by copying the characters from another given string.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithCString:encoding:">+&#xA0;stringWithCString:encoding:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string containing the bytes in a given C array, interpreted according to a given encoding.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithUTF8String:">+&#xA0;stringWithUTF8String:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string created by copying the data from a given C array of UTF8-encoded bytes.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW14" title="Creating and Initializing a String from a File"></a>
<h3 class="tasks">Creating and Initializing a String from a File</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithContentsOfFile:encoding:error:">+&#xA0;stringWithContentsOfFile:encoding:error:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string created by reading data from the file at a given path interpreted using a given encoding.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithContentsOfFile:encoding:error:">&#8211;&#xA0;initWithContentsOfFile:encoding:error:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <code>NSString</code> object initialized by reading data from the file at a given path using a given encoding.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithContentsOfFile:usedEncoding:error:">+&#xA0;stringWithContentsOfFile:usedEncoding:error:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string created by reading data from the file at a given path and returns by reference the encoding used to interpret the file.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithContentsOfFile:usedEncoding:error:">&#8211;&#xA0;initWithContentsOfFile:usedEncoding:error:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <code>NSString</code> object initialized by reading data from the file at a given path and returns by reference the encoding used to interpret the characters. ' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW15" title="Creating and Initializing a String from an URL"></a>
<h3 class="tasks">Creating and Initializing a String from an URL</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithContentsOfURL:encoding:error:">+&#xA0;stringWithContentsOfURL:encoding:error:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string created by reading data from a given URL interpreted using a given encoding.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithContentsOfURL:encoding:error:">&#8211;&#xA0;initWithContentsOfURL:encoding:error:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <code>NSString</code> object initialized by reading data from a given URL interpreted using a given encoding. ' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithContentsOfURL:usedEncoding:error:">+&#xA0;stringWithContentsOfURL:usedEncoding:error:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string created by reading data from a given URL and returns by reference the encoding used to interpret the data.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithContentsOfURL:usedEncoding:error:">&#8211;&#xA0;initWithContentsOfURL:usedEncoding:error:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <code>NSString</code> object initialized by reading data from a given URL and returns by reference the encoding used to interpret the data. ' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW16" title="Writing to a File or URL"></a>
<h3 class="tasks">Writing to a File or URL</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/writeToFile:atomically:encoding:error:">&#8211;&#xA0;writeToFile:atomically:encoding:error:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Writes the contents of the receiver to a file at a given path using a given encoding. ' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/writeToURL:atomically:encoding:error:">&#8211;&#xA0;writeToURL:atomically:encoding:error:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Writes the contents of the receiver to the URL specified by <em>url</em> using the specified encoding. ' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW17" title="Getting a String’s Length"></a>
<h3 class="tasks">Getting a String’s Length</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/length">&#8211;&#xA0;length</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the number of Unicode characters in the receiver.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/lengthOfBytesUsingEncoding:">&#8211;&#xA0;lengthOfBytesUsingEncoding:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the number of bytes required to store the receiver in a given encoding.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/maximumLengthOfBytesUsingEncoding:">&#8211;&#xA0;maximumLengthOfBytesUsingEncoding:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the maximum number of bytes needed to store the receiver in a given encoding.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW18" title="Getting Characters and Bytes"></a>
<h3 class="tasks">Getting Characters and Bytes</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/characterAtIndex:">&#8211;&#xA0;characterAtIndex:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the character at a given array position.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/getCharacters:">&#8211;&#xA0;getCharacters:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Copies all characters from the receiver into a given buffer.&#032;(<span style="color:red">Deprecated.</span>&#032;This method is unsafe because it could potentially cause buffer overruns. Use <code>getCharacters:range:</code> instead.)' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/getCharacters:range:">&#8211;&#xA0;getCharacters:range:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Copies characters from a given range in the receiver into a given buffer.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/getBytes:maxLength:usedLength:encoding:options:range:remainingRange:">&#8211;&#xA0;getBytes:maxLength:usedLength:encoding:options:range:remainingRange:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Gets a given range of characters as bytes in a specified encoding.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW20" title="Getting C Strings"></a>
<h3 class="tasks">Getting C Strings</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/cStringUsingEncoding:">&#8211;&#xA0;cStringUsingEncoding:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a representation of the receiver as a C string using a given encoding.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/getCString:maxLength:encoding:">&#8211;&#xA0;getCString:maxLength:encoding:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Converts the receiver’s content to a given encoding and stores them in a buffer.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/UTF8String">&#8211;&#xA0;UTF8String</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a null-terminated UTF8 representation of the receiver.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW21" title="Combining Strings"></a>
<h3 class="tasks">Combining Strings</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByAppendingFormat:">&#8211;&#xA0;stringByAppendingFormat:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string made by appending to the receiver a string constructed from a given format string and the following arguments.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByAppendingString:">&#8211;&#xA0;stringByAppendingString:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string made by appending a given string to the receiver.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByPaddingToLength:withString:startingAtIndex:">&#8211;&#xA0;stringByPaddingToLength:withString:startingAtIndex:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string formed from the receiver by either removing characters from the end, or by appending as many occurrences as necessary of a given pad string.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW22" title="Dividing Strings"></a>
<h3 class="tasks">Dividing Strings</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/componentsSeparatedByString:">&#8211;&#xA0;componentsSeparatedByString:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an array containing substrings from the receiver that have been divided by a given separator.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/componentsSeparatedByCharactersInSet:">&#8211;&#xA0;componentsSeparatedByCharactersInSet:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an array containing substrings from the receiver that have been divided by characters in a given set.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByTrimmingCharactersInSet:">&#8211;&#xA0;stringByTrimmingCharactersInSet:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string made by removing from both ends of the receiver characters contained in a given character set.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/substringFromIndex:">&#8211;&#xA0;substringFromIndex:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string containing the characters of the receiver from the one at a given index to the end.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/substringWithRange:">&#8211;&#xA0;substringWithRange:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string object containing the characters of the receiver that lie within a given range.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/substringToIndex:">&#8211;&#xA0;substringToIndex:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string containing the characters of the receiver up to, but not including, the one at a given index.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW23" title="Finding Characters and Substrings"></a>
<h3 class="tasks">Finding Characters and Substrings</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/rangeOfCharacterFromSet:">&#8211;&#xA0;rangeOfCharacterFromSet:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Finds and returns the range in the receiver of the first character from a given character set.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/rangeOfCharacterFromSet:options:">&#8211;&#xA0;rangeOfCharacterFromSet:options:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Finds and returns the range in the receiver of the first character, using given options, from a given character set.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/rangeOfCharacterFromSet:options:range:">&#8211;&#xA0;rangeOfCharacterFromSet:options:range:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Finds and returns the range in the receiver of the first character from a given character set found in a given range with given options.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/rangeOfString:">&#8211;&#xA0;rangeOfString:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Finds and returns the range of the first occurrence of a given string within the receiver.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/rangeOfString:options:">&#8211;&#xA0;rangeOfString:options:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Finds and returns the range of the first occurrence of a given string within the receiver, subject to given options.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/rangeOfString:options:range:">&#8211;&#xA0;rangeOfString:options:range:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Finds and returns the range of the first occurrence of a given string, within the given range of the receiver, subject to given options.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/rangeOfString:options:range:locale:">&#8211;&#xA0;rangeOfString:options:range:locale:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Finds and returns the range of the first occurrence of a given string within a given range of the receiver, subject to given options, using the specified locale, if any.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW25" title="Replacing Substrings"></a>
<h3 class="tasks">Replacing Substrings</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByReplacingOccurrencesOfString:withString:">&#8211;&#xA0;stringByReplacingOccurrencesOfString:withString:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string in which all occurrences of a target string in the receiver are replaced by another given string.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByReplacingOccurrencesOfString:withString:options:range:">&#8211;&#xA0;stringByReplacingOccurrencesOfString:withString:options:range:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string in which all occurrences of a target string in a specified range of the receiver are replaced by another given string.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByReplacingCharactersInRange:withString:">&#8211;&#xA0;stringByReplacingCharactersInRange:withString:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string in which the characters in a specified range of the receiver are replaced by a given string.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW26" title="Determining Line and Paragraph Ranges"></a>
<h3 class="tasks">Determining Line and Paragraph Ranges</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/getLineStart:end:contentsEnd:forRange:">&#8211;&#xA0;getLineStart:end:contentsEnd:forRange:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns by reference the beginning of the first line and the end of the last line touched by the given range.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/lineRangeForRange:">&#8211;&#xA0;lineRangeForRange:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the range of characters representing the line or lines containing a given range.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/getParagraphStart:end:contentsEnd:forRange:">&#8211;&#xA0;getParagraphStart:end:contentsEnd:forRange:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns by reference the beginning of the first paragraph and the end of the last paragraph touched by the given range.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/paragraphRangeForRange:">&#8211;&#xA0;paragraphRangeForRange:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the range of characters representing the paragraph or paragraphs containing a given range.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW27" title="Determining Composed Character Sequences"></a>
<h3 class="tasks">Determining Composed Character Sequences</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/rangeOfComposedCharacterSequenceAtIndex:">&#8211;&#xA0;rangeOfComposedCharacterSequenceAtIndex:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the range in the receiver of the composed character sequence located at a given index.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/rangeOfComposedCharacterSequencesForRange:">&#8211;&#xA0;rangeOfComposedCharacterSequencesForRange:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the range in the receiver of the composed character sequences in a given range.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW28" title="Converting String Contents Into a Property List"></a>
<h3 class="tasks">Converting String Contents Into a Property List</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/propertyList">&#8211;&#xA0;propertyList</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Parses the receiver as a text representation of a property list, returning an <code>NSString</code>, <code>NSData</code>, <code>NSArray</code>, or <code>NSDictionary</code> object, according to the topmost element.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/propertyListFromStringsFileFormat">&#8211;&#xA0;propertyListFromStringsFileFormat</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a dictionary object initialized with the keys and values found in the receiver.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW29" title="Identifying and Comparing Strings"></a>
<h3 class="tasks">Identifying and Comparing Strings</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/caseInsensitiveCompare:">&#8211;&#xA0;caseInsensitiveCompare:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the result of invoking <code>compare:options:</code> with <code>NSCaseInsensitiveSearch</code> as the only option.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/localizedCaseInsensitiveCompare:">&#8211;&#xA0;localizedCaseInsensitiveCompare:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <code>NSComparisonResult</code> value that indicates the lexical ordering of the receiver and a given string using a case-insensitive, localized, comparison. ' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:">&#8211;&#xA0;compare:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the result of invoking <code>compare:options:range:</code> with no options and the receiver’s full extent as the range.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/localizedCompare:">&#8211;&#xA0;localizedCompare:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <code>NSComparisonResult</code> value that indicates the lexical ordering of the receiver and another given string using a localized comparison.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:">&#8211;&#xA0;compare:options:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the result of invoking <code>compare:options:range:</code> with a given mask as the options and the receiver’s full extent as the range.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:range:">&#8211;&#xA0;compare:options:range:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the result of invoking <code>compare:options:range:locale:</code> with a <code>nil</code> locale.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:range:locale:">&#8211;&#xA0;compare:options:range:locale:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <code>NSComparisonResult</code> value that indicates the lexical ordering of a specified range within the receiver and a given string.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/hasPrefix:">&#8211;&#xA0;hasPrefix:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a Boolean value that indicates whether a given string matches the beginning characters of the receiver.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/hasSuffix:">&#8211;&#xA0;hasSuffix:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a Boolean value that indicates whether a given string matches the ending characters of the receiver. ' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/isEqualToString:">&#8211;&#xA0;isEqualToString:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a Boolean value that indicates whether a given string is equal to the receiver using an literal Unicode-based comparison.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/hash">&#8211;&#xA0;hash</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an unsigned integer that can be used as a hash table address.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW30" title="Folding Strings"></a>
<h3 class="tasks">Folding Strings</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByFoldingWithOptions:locale:">&#8211;&#xA0;stringByFoldingWithOptions:locale:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string with the given character folding options applied.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW32" title="Getting a Shared Prefix"></a>
<h3 class="tasks">Getting a Shared Prefix</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/commonPrefixWithString:options:">&#8211;&#xA0;commonPrefixWithString:options:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string containing characters the receiver and a given string have in common, starting from the beginning of each up to the first characters that aren’t equivalent.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW33" title="Changing Case"></a>
<h3 class="tasks">Changing Case</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/capitalizedString">&#8211;&#xA0;capitalizedString</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a capitalized representation of the receiver.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/lowercaseString">&#8211;&#xA0;lowercaseString</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns lowercased representation of the receiver.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/uppercaseString">&#8211;&#xA0;uppercaseString</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an uppercased representation of the receiver.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW34" title="Getting Strings with Mapping"></a>
<h3 class="tasks">Getting Strings with Mapping</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/decomposedStringWithCanonicalMapping">&#8211;&#xA0;decomposedStringWithCanonicalMapping</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string made by normalizing the receiver’s contents using Form D.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/decomposedStringWithCompatibilityMapping">&#8211;&#xA0;decomposedStringWithCompatibilityMapping</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string made by normalizing the receiver’s contents using Form KD.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/precomposedStringWithCanonicalMapping">&#8211;&#xA0;precomposedStringWithCanonicalMapping</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string made by normalizing the receiver’s contents using Form C.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/precomposedStringWithCompatibilityMapping">&#8211;&#xA0;precomposedStringWithCompatibilityMapping</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string made by normalizing the receiver’s contents using Form KC.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW35" title="Getting Numeric Values"></a>
<h3 class="tasks">Getting Numeric Values</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/doubleValue">&#8211;&#xA0;doubleValue</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the floating-point value of the receiver’s text as a <code>double</code>.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/floatValue">&#8211;&#xA0;floatValue</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the floating-point value of the receiver’s text as a <code>float</code>.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/intValue">&#8211;&#xA0;intValue</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the integer value of the receiver’s text.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/integerValue">&#8211;&#xA0;integerValue</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the <code>NSInteger</code> value of the receiver’s text.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/longLongValue">&#8211;&#xA0;longLongValue</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the <code>long long</code> value of the receiver’s text.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/boolValue">&#8211;&#xA0;boolValue</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the Boolean value of the receiver’s text.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW37" title="Working with Encodings"></a>
<h3 class="tasks">Working with Encodings</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/clm/NSString/availableStringEncodings">+&#xA0;availableStringEncodings</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a zero-terminated list of the encodings string objects support in the application’s environment.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/clm/NSString/defaultCStringEncoding">+&#xA0;defaultCStringEncoding</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the C-string encoding assumed for any method accepting a C string as an argument.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/clm/NSString/localizedNameOfStringEncoding:">+&#xA0;localizedNameOfStringEncoding:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a human-readable string giving the name of a given encoding.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/canBeConvertedToEncoding:">&#8211;&#xA0;canBeConvertedToEncoding:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a Boolean value that indicates whether the receiver can be converted to a given encoding without loss of information. ' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/dataUsingEncoding:">&#8211;&#xA0;dataUsingEncoding:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <code>NSData</code> object containing a representation of the receiver encoded using a given encoding.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/dataUsingEncoding:allowLossyConversion:">&#8211;&#xA0;dataUsingEncoding:allowLossyConversion:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an <code>NSData</code> object containing a representation of the receiver encoded using a given encoding.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/description">&#8211;&#xA0;description</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the receiver.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/fastestEncoding">&#8211;&#xA0;fastestEncoding</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the fastest encoding to which the receiver may be converted without loss of information.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/smallestEncoding">&#8211;&#xA0;smallestEncoding</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the smallest encoding to which the receiver can be converted without loss of information.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW38" title="Working with Paths"></a>
<h3 class="tasks">Working with Paths</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/clm/NSString/pathWithComponents:">+&#xA0;pathWithComponents:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a string built from the strings in a given array by concatenating them with a path separator between each pair.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/pathComponents">&#8211;&#xA0;pathComponents</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an array of <code>NSString</code> objects containing, in order, each path component of the receiver.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/completePathIntoString:caseSensitive:matchesIntoArray:filterTypes:">&#8211;&#xA0;completePathIntoString:caseSensitive:matchesIntoArray:filterTypes:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Interprets the receiver as a path in the file system and attempts to perform filename completion, returning a numeric value that indicates whether a match was possible, and by reference the longest path that matches the receiver. ' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/fileSystemRepresentation">&#8211;&#xA0;fileSystemRepresentation</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a file system-specific representation of the receiver. ' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/getFileSystemRepresentation:maxLength:">&#8211;&#xA0;getFileSystemRepresentation:maxLength:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Interprets the receiver as a system-independent path and fills a buffer with a C-string in a format and encoding suitable for use with file-system calls.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/isAbsolutePath">&#8211;&#xA0;isAbsolutePath</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returning a Boolean value that indicates whether the receiver represents an absolute path.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/lastPathComponent">&#8211;&#xA0;lastPathComponent</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns the last path component of the receiver.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/pathExtension">&#8211;&#xA0;pathExtension</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Interprets the receiver as a path and returns the receiver’s extension, if any.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByAbbreviatingWithTildeInPath">&#8211;&#xA0;stringByAbbreviatingWithTildeInPath</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string representing the receiver as a path with a tilde (<code>~</code>) substituted for the full path to the current user’s home directory.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByAppendingPathComponent:">&#8211;&#xA0;stringByAppendingPathComponent:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string made by appending to the receiver a given string.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByAppendingPathExtension:">&#8211;&#xA0;stringByAppendingPathExtension:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string made by appending to the receiver an extension separator followed by a given extension.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByDeletingLastPathComponent">&#8211;&#xA0;stringByDeletingLastPathComponent</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string made by deleting the last path component from the receiver, along with any final path separator.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByDeletingPathExtension">&#8211;&#xA0;stringByDeletingPathExtension</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string made by deleting the extension (if any, and only the last) from the receiver.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByExpandingTildeInPath">&#8211;&#xA0;stringByExpandingTildeInPath</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string made by expanding the initial component of the receiver to its full path value.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByResolvingSymlinksInPath">&#8211;&#xA0;stringByResolvingSymlinksInPath</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string made from the receiver by resolving all symbolic links and standardizing path. ' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByStandardizingPath">&#8211;&#xA0;stringByStandardizingPath</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string made by removing extraneous path components from the receiver.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringsByAppendingPaths:">&#8211;&#xA0;stringsByAppendingPaths:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns an array of strings made by separately appending to the receiver each string in in a given array.' />
</span></li>
</ul>
<a name="//apple_ref/doc/uid/20000154-SW39" title="Working with URLs"></a>
<h3 class="tasks">Working with URLs</h3>
<ul class="tooltip">
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByAddingPercentEscapesUsingEncoding:">&#8211;&#xA0;stringByAddingPercentEscapesUsingEncoding:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a representation of the receiver using a given encoding to determine the percent escapes necessary to convert the receiver into a legal URL string.' />
</span></li>
<li><span class="tooltip">
<code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByReplacingPercentEscapesUsingEncoding:">&#8211;&#xA0;stringByReplacingPercentEscapesUsingEncoding:</a></code>
<img src="../../../../../../../Resources/410/Images/info_icon.jpg" width="10" height="10" border="0" class="tooltipicon" data-abstract='Returns a new string made by replacing in the receiver all percent escapes with the matching characters as determined by a given encoding.' />
</span></li>
</ul>
</div><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_2" title="Class Methods"></a><h2 class="jump">Class Methods</h2><a name="//apple_ref/occ/clm/NSString/availableStringEncodings" title="availableStringEncodings"></a><a name="//apple_ref/doc/uid/20000154-availableStringEncodings" title="availableStringEncodings"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_37"></a><h3 class="jump classMethod">availableStringEncodings</h3>
<p class="spaceabove">Returns a zero-terminated list of the encodings string objects support in the application’s environment.</p><p class="spaceabovemethod">+ (const <a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a> *)availableStringEncodings</p><div class="return_value"><h5 class="tight">Return Value</h5><p>A zero-terminated list of the encodings string objects support in the application’s environment.</p></div>
<h5 class="tight">Discussion</h5><p>Among the more commonly used encodings are:</p><ul class="simple"><li>
<p><code><a href="NSString.html#//apple_ref/doc/c_ref/NSASCIIStringEncoding">NSASCIIStringEncoding</a></code></p></li>
<li><p><code><a href="NSString.html#//apple_ref/doc/c_ref/NSUnicodeStringEncoding">NSUnicodeStringEncoding</a></code></p></li>
<li><p><code><a href="NSString.html#//apple_ref/doc/c_ref/NSISOLatin1StringEncoding">NSISOLatin1StringEncoding</a></code></p></li>
<li><p><code><a href="NSString.html#//apple_ref/doc/c_ref/NSISOLatin2StringEncoding">NSISOLatin2StringEncoding</a></code></p></li>
<li><p><code><a href="NSString.html#//apple_ref/doc/c_ref/NSSymbolStringEncoding">NSSymbolStringEncoding</a></code></p></li></ul><p>See the <span class="content_text"><a href="NSString.html#//apple_ref/doc/uid/20000154-35474">“Constants”</a></span> section for a larger list and descriptions of many supported encodings. In addition to those encodings listed here, you can also use the encodings defined for CFString in Core Foundation; you just need to call the <code><a href="../../../../../../CoreFoundation/Reference/CFStringRef/Reference/reference.html#//apple_ref/c/func/CFStringConvertEncodingToNSStringEncoding" target="_top">CFStringConvertEncodingToNSStringEncoding</a></code> function to convert them to a usable format.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/localizedNameOfStringEncoding:">+&#xA0;localizedNameOfStringEncoding:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/clm/NSString/defaultCStringEncoding" title="defaultCStringEncoding"></a><a name="//apple_ref/doc/uid/20000154-defaultCStringEncoding" title="defaultCStringEncoding"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_38"></a><h3 class="jump classMethod">defaultCStringEncoding</h3>
<p class="spaceabove">Returns the C-string encoding assumed for any method accepting a C string as an argument.</p><p class="spaceabovemethod">+ (<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)defaultCStringEncoding</p><div class="return_value"><h5 class="tight">Return Value</h5><p>The C-string encoding assumed for any method accepting a C string as an argument.</p></div> <h5 class="tight">Discussion</h5><p>This method returns a user-dependent encoding who value is derived from user's default language and potentially other factors. You might sometimes need to use this encoding when interpreting user documents with unknown encodings, in the absence of other hints, but in general this encoding should be used rarely, if at all. Note that some potential values might result in unexpected encoding conversions of even fairly straightforward <code>NSString</code> content—for example, punctuation characters with a bidirectional encoding.</p><p>Methods that accept a C string as an argument use <code>...CString...</code> in the keywords for such arguments: for example, <code>stringWithCString:</code>—note, though, that these are deprecated. The default C-string encoding is determined from system information and can’t be changed programmatically for an individual process. See <span class="content_text"><a href="NSString.html#//apple_ref/doc/constant_group/String_Encodings">“String Encodings”</a></span> for a full list of supported encodings.</p><div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/clm/NSString/localizedNameOfStringEncoding:" title="localizedNameOfStringEncoding:"></a><a name="//apple_ref/doc/uid/20000154-localizedNameOfStringEncoding_" title="localizedNameOfStringEncoding:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_39"></a><h3 class="jump classMethod">localizedNameOfStringEncoding:</h3>
<p class="spaceabove">Returns a human-readable string giving the name of a given encoding.</p><p class="spaceabovemethod">+ (NSString *)localizedNameOfStringEncoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)<em>encoding</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>encoding</em></dt><dd><p>A string encoding.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>A human-readable string giving the name of <em>encoding</em> in the current locale’s language.</p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/clm/NSString/localizedStringWithFormat:" title="localizedStringWithFormat:"></a><a name="//apple_ref/doc/uid/20000154-localizedStringWithFormat_" title="localizedStringWithFormat:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_40"></a><h3 class="jump classMethod">localizedStringWithFormat:</h3>
<p class="spaceabove">Returns a string created by using a given format string as a template into which the remaining argument values are substituted according to the user's default locale.</p><p class="spaceabovemethod">+ (id)localizedStringWithFormat:(NSString *)<em>format</em> <em>...</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>format</em></dt><dd><p>A format string. See <span class="content_text"><a href="../../../../../Conceptual/Strings/Articles/FormatStrings.html#//apple_ref/doc/uid/20000943" target="_top">Formatting String Objects</a></span> for examples of how to use this method, and <span class="content_text"><a href="../../../../../Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265" target="_top">String Format Specifiers</a></span> for a list of format specifiers. This value must not be <code>nil</code>.</p><div class="importantboxdef"><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_5" title="Important:"></a><p><strong>Important:</strong>&nbsp;Raises an <code><a href="../../../Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSInvalidArgumentException" target="_top">NSInvalidArgumentException</a></code> if <em>format</em> is <code>nil</code>.</p><p></p></div></dd><dt><em>...</em></dt><dd><p>A comma-separated list of arguments to substitute into <em>format</em>. </p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>A string created by using <em>format</em> as a template into which the following argument values are substituted according to the formatting information to the user's default locale.</p></div>
<h5 class="tight">Discussion</h5><p>This method is equivalent to using <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithFormat:locale:" target="_self">initWithFormat:locale:</a></code> and passing <code>[[NSUserDefaults standardUserDefaults] dictionaryRepresentation]</code> as the locale argument.</p><p>As an example of formatting, this method replaces the decimal according to the locale in <code>%f</code> and <code>%d</code> substitutions, and calls <code>descriptionWithLocale:</code> instead of <code>description</code> where necessary.</p><p>This code excerpt creates a string from another string and a float:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>NSString *myString = [NSString localizedStringWithFormat:@"%@: %f\n", @"Cost", 1234.56];<span></span></pre></td></tr></table></div><p>The resulting string has the value “<code>Cost: 1234.560000\n</code>” if the locale is <code>en_US</code>, and “<code>Cost: 1234,560000\n</code>” if the locale is <code>fr_FR</code>.</p><p>See <span class="content_text"><a href="../../../../../Conceptual/Strings/Articles/FormatStrings.html#//apple_ref/doc/uid/20000943" target="_top">Formatting String Objects</a></span> for more information.</p><div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability"><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithFormat:">+&#xA0;stringWithFormat:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithFormat:locale:">&#8211;&#xA0;initWithFormat:locale:</a></code></li></ul>
<div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/clm/NSString/pathWithComponents:" title="pathWithComponents:"></a><a name="//apple_ref/doc/uid/20000154-pathWithComponents_" title="pathWithComponents:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_41"></a>
<h3 class="jump classMethod">pathWithComponents:</h3>
<p class="spaceabove">Returns a string built from the strings in a given array by concatenating them with a path separator between each pair.</p><p class="spaceabovemethod">+ (NSString *)pathWithComponents:(<a href="../../NSArray_Class/NSArray.html#//apple_ref/doc/c_ref/NSArray" target="_top">NSArray</a> *)<em>components</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>components</em></dt><dd><p>An array of <code>NSString</code> objects representing a file path. To create an absolute path, use a slash mark (“<code>/</code>”) as the first component. To include a trailing path divider, use an empty string as the last component. </p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>A string built from the strings in <em>components</em> by concatenating them (in the order they appear in the array) with a path separator between each pair.</p></div>
<h5 class="tight">Discussion</h5><p>This method doesn’t clean up the path created; use <code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByStandardizingPath">stringByStandardizingPath</a></code> to resolve empty components, references to the parent directory, and so on.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/pathComponents">&#8211;&#xA0;pathComponents</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSPathUtilities.h</code></div><a name="//apple_ref/occ/clm/NSString/string" title="string"></a><a name="//apple_ref/doc/uid/20000154-string" title="string"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_42"></a>
<h3 class="jump classMethod">string</h3>
<p class="spaceabove">Returns an empty string.</p><p class="spaceabovemethod">+ (id)string</p><div class="return_value"><h5 class="tight">Return Value</h5><p>An empty string.</p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/init">&#8211;&#xA0;init</a></code></li></ul><h5 class="tight">Related Sample Code</h5><ul class="availability"><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/HelloWorld_iPhone/index.html#//apple_ref/doc/uid/DTS40007709" target="_top">HelloWorld</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/iPhoneUnitTests/index.html#//apple_ref/doc/uid/DTS40008868" target="_top">iPhoneUnitTests</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/LazyTableImages/index.html#//apple_ref/doc/uid/DTS40009394" target="_top">LazyTableImages</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/SeismicXML/index.html#//apple_ref/doc/uid/DTS40007323" target="_top">SeismicXML</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/XMLPerformance/index.html#//apple_ref/doc/uid/DTS40008094" target="_top">XMLPerformance</a></span></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/clm/NSString/stringWithCharacters:length:" title="stringWithCharacters:length:"></a><a name="//apple_ref/doc/uid/20000154-stringWithCharacters_length_" title="stringWithCharacters:length:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_43"></a><h3 class="jump classMethod">stringWithCharacters:length:</h3><p class="spaceabove">Returns a string containing a given number of characters taken from a given C array of Unicode characters.</p><p class="spaceabovemethod">+ (id)stringWithCharacters:(const <a href="NSString.html#//apple_ref/doc/c_ref/unichar">unichar</a> *)<em>chars</em> length:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a>)<em>length</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>chars</em></dt><dd><p>A C array of Unicode characters; the value must not be <code>NULL</code>.</p><div class="importantboxdef"><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_6" title="Important:"></a><p><strong>Important:</strong>&nbsp;Raises an exception if <em>chars</em> is <code>NULL</code>, even if <em>length</em> is <code>0</code>.</p><p></p></div></dd><dt><em>length</em></dt><dd><p>The number of characters to use from <em>chars</em>.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>A string containing <em>length</em> Unicode characters taken (starting with the first) from <em>chars</em>. </p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithCharacters:length:">&#8211;&#xA0;initWithCharacters:length:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/clm/NSString/stringWithContentsOfFile:encoding:error:" title="stringWithContentsOfFile:encoding:error:"></a><a name="//apple_ref/doc/uid/20000154-BAJIAAFJ" title="stringWithContentsOfFile:encoding:error:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_45"></a>
<h3 class="jump classMethod">stringWithContentsOfFile:encoding:error:</h3>
<p class="spaceabove">Returns a string created by reading data from the file at a given path interpreted using a given encoding.</p><p class="spaceabovemethod">+ (id)stringWithContentsOfFile:(NSString *)<em>path</em> encoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)<em>enc</em> error:(<a href="../../NSError_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSError" target="_top">NSError</a> **)<em>error</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>path</em></dt><dd><p>A path to a file.</p></dd><dt><em>enc</em></dt><dd><p>The encoding of the file at <em>path</em>.</p></dd><dt><em>error</em></dt><dd><p>If an error occurs, upon returns contains an <code>NSError</code> object that describes the problem. If you are not interested in possible errors, pass in <code>NULL</code>.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>A string created by reading data from the file named by <em>path</em> using the encoding, <em>enc</em>. If the file can’t be opened or there is an encoding error, returns <code>nil</code>.</p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithContentsOfFile:encoding:error:">&#8211;&#xA0;initWithContentsOfFile:encoding:error:</a></code></li></ul><h5 class="tight">Related Sample Code</h5><ul class="availability"><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/AQOfflineRenderTest/index.html#//apple_ref/doc/uid/DTS40008413" target="_top">AQOfflineRenderTest</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/iPhoneExtAudioFileConvertTest/index.html#//apple_ref/doc/uid/DTS40009222" target="_top">iPhoneExtAudioFileConvertTest</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/iPhoneMultichannelMixerTest/index.html#//apple_ref/doc/uid/DTS40009113" target="_top">iPhoneMultichannelMixerTest</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/MoveMe/index.html#//apple_ref/doc/uid/DTS40007315" target="_top">MoveMe</a></span></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/clm/NSString/stringWithContentsOfFile:usedEncoding:error:" title="stringWithContentsOfFile:usedEncoding:error:"></a><a name="//apple_ref/doc/uid/20000154-BAJDDJEF" title="stringWithContentsOfFile:usedEncoding:error:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_46"></a>
<h3 class="jump classMethod">stringWithContentsOfFile:usedEncoding:error:</h3>
<p class="spaceabove">Returns a string created by reading data from the file at a given path and returns by reference the encoding used to interpret the file.</p><p class="spaceabovemethod">+ (id)stringWithContentsOfFile:(NSString *)<em>path</em> usedEncoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a> *)<em>enc</em> error:(<a href="../../NSError_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSError" target="_top">NSError</a> **)<em>error</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>path</em></dt><dd><p>A path to a file.</p></dd><dt><em>enc</em></dt><dd><p>Upon return, if the file is read successfully, contains the encoding used to interpret the file at <em>path</em>.</p></dd><dt><em>error</em></dt><dd><p>If an error occurs, upon returns contains an <code>NSError</code> object that describes the problem. If you are not interested in possible errors, you may pass in <code>NULL</code>.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>A string created by reading data from the file named by <em>path</em>. If the file can’t be opened or there is an encoding error, returns <code>nil</code>.</p></div>
<h5 class="tight">Discussion</h5><p>This method attempts to determine the encoding of the file at <em>path</em>. </p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithContentsOfFile:encoding:error:">&#8211;&#xA0;initWithContentsOfFile:encoding:error:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/clm/NSString/stringWithContentsOfURL:encoding:error:" title="stringWithContentsOfURL:encoding:error:"></a><a name="//apple_ref/doc/uid/20000154-BAJBFBJC" title="stringWithContentsOfURL:encoding:error:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_48"></a>
<h3 class="jump classMethod">stringWithContentsOfURL:encoding:error:</h3>
<p class="spaceabove">Returns a string created by reading data from a given URL interpreted using a given encoding.</p><p class="spaceabovemethod">+ (id)stringWithContentsOfURL:(<a href="../../NSURL_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSURL" target="_top">NSURL</a> *)<em>url</em> encoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)<em>enc</em> error:(<a href="../../NSError_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSError" target="_top">NSError</a> **)<em>error</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>url</em></dt><dd><p>The URL to read.</p></dd><dt><em>enc</em></dt><dd><p>The encoding of the data at <em>url</em>.</p></dd><dt><em>error</em></dt><dd><p>If an error occurs, upon returns contains an <code>NSError</code> object that describes the problem. If you are not interested in possible errors, you may pass in <code>NULL</code>.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>A string created by reading data from <em>URL</em> using the encoding, <em>enc</em>. If the URL can’t be opened or there is an encoding error, returns <code>nil</code>.</p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithContentsOfURL:usedEncoding:error:">+&#xA0;stringWithContentsOfURL:usedEncoding:error:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithContentsOfURL:encoding:error:">&#8211;&#xA0;initWithContentsOfURL:encoding:error:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/clm/NSString/stringWithContentsOfURL:usedEncoding:error:" title="stringWithContentsOfURL:usedEncoding:error:"></a><a name="//apple_ref/doc/uid/20000154-BAJHDDAJ" title="stringWithContentsOfURL:usedEncoding:error:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_49"></a>
<h3 class="jump classMethod">stringWithContentsOfURL:usedEncoding:error:</h3>
<p class="spaceabove">Returns a string created by reading data from a given URL and returns by reference the encoding used to interpret the data.</p><p class="spaceabovemethod">+ (id)stringWithContentsOfURL:(<a href="../../NSURL_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSURL" target="_top">NSURL</a> *)<em>url</em> usedEncoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a> *)<em>enc</em> error:(<a href="../../NSError_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSError" target="_top">NSError</a> **)<em>error</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>url</em></dt><dd><p>The URL from which to read data.</p></dd><dt><em>enc</em></dt><dd><p>Upon return, if <em>url</em> is read successfully, contains the encoding used to interpret the data.</p></dd><dt><em>error</em></dt><dd><p>If an error occurs, upon returns contains an <code>NSError</code> object that describes the problem. If you are not interested in possible errors, you may pass in <code>NULL</code>.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>A string created by reading data from <em>url</em>. If the URL can’t be opened or there is an encoding error, returns <code>nil</code>.</p></div>
<h5 class="tight">Discussion</h5><p>This method attempts to determine the encoding at <em>url</em>.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithContentsOfURL:encoding:error:">+&#xA0;stringWithContentsOfURL:encoding:error:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithContentsOfURL:usedEncoding:error:">&#8211;&#xA0;initWithContentsOfURL:usedEncoding:error:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/clm/NSString/stringWithCString:encoding:" title="stringWithCString:encoding:"></a><a name="//apple_ref/doc/uid/20000154-BAJCCGHJ" title="stringWithCString:encoding:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_51"></a>
<h3 class="jump classMethod">stringWithCString:encoding:</h3>
<p class="spaceabove">Returns a string containing the bytes in a given C array, interpreted according to a given encoding.</p><p class="spaceabovemethod">+ (id)stringWithCString:(const char *)<em>cString</em> encoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)<em>enc</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>cString</em></dt><dd><p>A C array of bytes. The array must end with a <code>NULL</code> character; intermediate <code>NULL</code> characters are not allowed.</p></dd><dt><em>enc</em></dt><dd><p>The encoding of <em>cString</em>.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>A string containing the characters described in <em>cString</em>.</p></div>
<h5 class="tight">Discussion</h5><p>If <em>cString</em> is not a <code>NULL</code>-terminated C string, or <em>encoding</em> does not match the actual encoding, the results are undefined.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithCString:encoding:">&#8211;&#xA0;initWithCString:encoding:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/clm/NSString/stringWithFormat:" title="stringWithFormat:"></a><a name="//apple_ref/doc/uid/20000154-stringWithFormat_" title="stringWithFormat:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_53"></a>
<h3 class="jump classMethod">stringWithFormat:</h3>
<p class="spaceabove">Returns a string created by using a given format string as a template into which the remaining argument values are substituted.</p><p class="spaceabovemethod">+ (id)stringWithFormat:(NSString *)<em>format,</em> <em>...</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>format</em></dt><dd><p>A format string. See <span class="content_text"><a href="../../../../../Conceptual/Strings/Articles/FormatStrings.html#//apple_ref/doc/uid/20000943" target="_top">Formatting String Objects</a></span> for examples of how to use this method, and <span class="content_text"><a href="../../../../../Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265" target="_top">String Format Specifiers</a></span> for a list of format specifiers. This value must not be <code>nil</code>.</p><div class="importantboxdef"><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_7" title="Important:"></a><p><strong>Important:</strong>&nbsp;Raises an <code><a href="../../../Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSInvalidArgumentException" target="_top">NSInvalidArgumentException</a></code> if <em>format</em> is <code>nil</code>.</p><p></p></div></dd><dt><em>...</em></dt><dd><p>A comma-separated list of arguments to substitute into <em>format</em>. </p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>A string created by using <em>format</em> as a template into which the remaining argument values are substituted according to the canonical locale.</p></div> <h5 class="tight">Discussion</h5><p>This method is similar to <code><a href="NSString.html#//apple_ref/occ/clm/NSString/localizedStringWithFormat:">localizedStringWithFormat:</a></code>, but using the canonical locale to format numbers. This is useful, for example, if you want to produce “non-localized” formatting which needs to be written out to files and parsed back later.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability"><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithFormat:">&#8211;&#xA0;initWithFormat:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/localizedStringWithFormat:">+&#xA0;localizedStringWithFormat:</a></code></li></ul><h5 class="tight">Related Sample Code</h5><ul class="availability"><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/Formulaic/index.html#//apple_ref/doc/uid/DTS40008932" target="_top">Formulaic</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/LocateMe/index.html#//apple_ref/doc/uid/DTS40007801" target="_top">LocateMe</a></span></li><li class="availability"> <span class="content_text"><a href="./https:/devpubsbuild2.apple.com/Messier/Releases/WildcatDevCenter/samplecode/SimpleFTPSample/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009243">SimpleFTPSample</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/SimpleURLConnections/index.html#//apple_ref/doc/uid/DTS40009245" target="_top">SimpleURLConnections</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/TheElements/index.html#//apple_ref/doc/uid/DTS40007419" target="_top">TheElements</a></span></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/clm/NSString/stringWithString:" title="stringWithString:"></a><a name="//apple_ref/doc/uid/20000154-stringWithString_" title="stringWithString:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_54"></a>
<h3 class="jump classMethod">stringWithString:</h3><p class="spaceabove">Returns a string created by copying the characters from another given string.</p><p class="spaceabovemethod">+ (id)stringWithString:(NSString *)<em>aString</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>aString</em></dt><dd><p>The string from which to copy characters. This value must not be <code>nil</code>.</p><div class="importantboxdef"><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_8" title="Important:"></a><p><strong>Important:</strong>&nbsp;Raises an <code><a href="../../../Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSInvalidArgumentException" target="_top">NSInvalidArgumentException</a></code> if <em>aString</em> is <code>nil</code>.</p><p></p></div></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>A string created by copying the characters from <em>aString</em>.</p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithString:">&#8211;&#xA0;initWithString:</a></code></li></ul><h5 class="tight">Related Sample Code</h5><ul class="availability"><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/BonjourWeb/index.html#//apple_ref/doc/uid/DTS40007415" target="_top">BonjourWeb</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/Formulaic/index.html#//apple_ref/doc/uid/DTS40008932" target="_top">Formulaic</a></span></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/clm/NSString/stringWithUTF8String:" title="stringWithUTF8String:"></a><a name="//apple_ref/doc/uid/20000154-CJBGJGID" title="stringWithUTF8String:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_55"></a>
<h3 class="jump classMethod">stringWithUTF8String:</h3>
<p class="spaceabove">Returns a string created by copying the data from a given C array of UTF8-encoded bytes.</p><p class="spaceabovemethod">+ (id)stringWithUTF8String:(const char *)<em>bytes</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>bytes</em></dt><dd><p>A <code>NULL</code>-terminated C array of bytes in UTF8 encoding. </p><div class="importantboxdef"><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_9" title="Important:"></a><p><strong>Important:</strong>&nbsp;Raises an exception if <em>bytes</em> is <code>NULL</code>.</p><p></p></div></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>A string created by copying the data from <em>bytes</em>.</p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithString:">&#8211;&#xA0;initWithString:</a></code></li></ul><h5 class="tight">Related Sample Code</h5><ul class="availability"><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/avTouch/index.html#//apple_ref/doc/uid/DTS40008636" target="_top">avTouch</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/BonjourWeb/index.html#//apple_ref/doc/uid/DTS40007415" target="_top">BonjourWeb</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/CryptoExercise/index.html#//apple_ref/doc/uid/DTS40008019" target="_top">CryptoExercise</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/GLImageProcessing/index.html#//apple_ref/doc/uid/DTS40009053" target="_top">GLImageProcessing</a></span></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><div id="InstanceMethods_section" class="zInstanceMethods"><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_3" title="Instance Methods"></a><h2 class="jump">Instance Methods</h2><a name="//apple_ref/occ/instm/NSString/boolValue" title="boolValue"></a><a name="//apple_ref/doc/uid/20000154-SW36" title="boolValue"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_56"></a><h3 class="jump instanceMethod">boolValue</h3><p class="spaceabove">Returns the Boolean value of the receiver’s text.</p><p class="spaceabovemethod">- (BOOL)boolValue</p><div class="return_value"><h5 class="tight">Return Value</h5><p>The Boolean value of the receiver’s text. Returns <code>YES</code> on encountering one of "Y", "y", "T", "t", or a digit 1-9—the method ignores any trailing characters. Returns <code>NO</code> if the receiver doesn’t begin with a valid decimal text representation of a number.</p></div> <h5 class="tight">Discussion</h5><p>The method assumes a decimal representation and skips whitespace at the beginning of the string. It also skips initial whitespace characters, or optional -/+ sign followed by zeroes. </p><div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability"><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/integerValue">&#8211;&#xA0;integerValue</a></code></li><li class="availability"> <code><a href="../../NSScanner_Class/Reference/Reference.html#//apple_ref/occ/instm/NSScanner/scanInt:" target="_top">&#8211;&#xA0;scanInt:</a></code> (<code>NSScanner</code>)</li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/canBeConvertedToEncoding:" title="canBeConvertedToEncoding:"></a><a name="//apple_ref/doc/uid/20000154-canBeConvertedToEncoding_" title="canBeConvertedToEncoding:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_57"></a><h3 class="jump instanceMethod">canBeConvertedToEncoding:</h3>
<p class="spaceabove">Returns a Boolean value that indicates whether the receiver can be converted to a given encoding without loss of information. </p><p class="spaceabovemethod">- (BOOL)canBeConvertedToEncoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)<em>encoding</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>encoding</em></dt><dd><p>A string encoding.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p><code>YES</code> if the receiver can be converted to <em>encoding</em> without loss of information. Returns <code>NO</code> if characters would have to be changed or deleted in the process of changing encodings.</p></div>
<h5 class="tight">Discussion</h5><p>If you plan to actually convert a string, the <code>dataUsingEncoding:...</code> methods return <code>nil</code> on failure, so you can avoid the overhead of invoking this method yourself by simply trying to convert the string.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/dataUsingEncoding:allowLossyConversion:">&#8211;&#xA0;dataUsingEncoding:allowLossyConversion:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/capitalizedString" title="capitalizedString"></a><a name="//apple_ref/doc/uid/20000154-capitalizedString" title="capitalizedString"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_58"></a>
<h3 class="jump instanceMethod">capitalizedString</h3>
<p class="spaceabove">Returns a capitalized representation of the receiver.</p><p class="spaceabovemethod">- (NSString *)capitalizedString</p><div class="return_value"><h5 class="tight">Return Value</h5><p>A string with the first character from each word in the receiver changed to its corresponding uppercase value, and all remaining characters set to their corresponding lowercase values.</p></div>
<h5 class="tight">Discussion</h5><p>A “word” here is any sequence of characters delimited by spaces, tabs, or line terminators (listed under <code><a href="NSString.html#//apple_ref/occ/instm/NSString/getLineStart:end:contentsEnd:forRange:">getLineStart:end:contentsEnd:forRange:</a></code>). Other common word delimiters such as hyphens and other punctuation aren’t considered, so this method may not generally produce the desired results for multiword strings.</p><p>Case transformations aren’t guaranteed to be symmetrical or to produce strings of the same lengths as the originals. See <code><a href="NSString.html#//apple_ref/occ/instm/NSString/lowercaseString">lowercaseString</a></code> for an example.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/lowercaseString">&#8211;&#xA0;lowercaseString</a></code></li>
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/uppercaseString">&#8211;&#xA0;uppercaseString</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/caseInsensitiveCompare:" title="caseInsensitiveCompare:"></a><a name="//apple_ref/doc/uid/20000154-caseInsensitiveCompare_" title="caseInsensitiveCompare:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_59"></a>
<h3 class="jump instanceMethod">caseInsensitiveCompare:</h3>
<p class="spaceabove">Returns the result of invoking <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:">compare:options:</a></code> with <code><a href="NSString.html#//apple_ref/doc/c_ref/NSCaseInsensitiveSearch">NSCaseInsensitiveSearch</a></code> as the only option.</p><p class="spaceabovemethod">- (<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSComparisonResult" target="_top">NSComparisonResult</a>)caseInsensitiveCompare:(NSString *)<em>aString</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>aString</em></dt><dd><p>The string with which to compare the receiver. </p><p>This value must not be <code>nil</code>. If this value is <code>nil</code>, the behavior is undefined and may change in future versions of Mac OS X.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>The result of invoking <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:">compare:options:</a></code> with <code><a href="NSString.html#//apple_ref/doc/c_ref/NSCaseInsensitiveSearch">NSCaseInsensitiveSearch</a></code> as the only option.</p></div> <h5 class="tight">Discussion</h5><p>If you are comparing strings to present to the end-user, you should typically use <code><a href="NSString.html#//apple_ref/occ/instm/NSString/localizedCaseInsensitiveCompare:">localizedCaseInsensitiveCompare:</a></code> instead.</p><div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability"><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/localizedCaseInsensitiveCompare:">&#8211;&#xA0;localizedCaseInsensitiveCompare:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:">&#8211;&#xA0;compare:options:</a></code></li></ul>
<h5 class="tight">Related Sample Code</h5><ul class="availability"><li class="availability"> <span class="content_text"><a href="./https:/devpubsbuild2.apple.com/Messier/Releases/WildcatDevCenter/samplecode/SimpleFTPSample/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009243">SimpleFTPSample</a></span></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/characterAtIndex:" title="characterAtIndex:"></a><a name="//apple_ref/doc/uid/20000154-characterAtIndex_" title="characterAtIndex:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_60"></a>
<h3 class="jump instanceMethod">characterAtIndex:</h3>
<p class="spaceabove">Returns the character at a given array position.</p><p class="spaceabovemethod">- (<a href="NSString.html#//apple_ref/doc/c_ref/unichar">unichar</a>)characterAtIndex:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a>)<em>index</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>index</em></dt><dd><p>The index of the character to retrieve. The index value must not lie outside the bounds of the receiver.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>The character at the array position given by <em>index</em>.</p></div>
<h5 class="tight">Discussion</h5><p>Raises an <code><a href="../../../Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSRangeException" target="_top">NSRangeException</a></code> if <em>index</em> lies beyond the end of the receiver.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability"><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/getCharacters:range:">&#8211;&#xA0;getCharacters:range:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/commonPrefixWithString:options:" title="commonPrefixWithString:options:"></a><a name="//apple_ref/doc/uid/20000154-commonPrefixWithString_options_" title="commonPrefixWithString:options:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_61"></a><h3 class="jump instanceMethod">commonPrefixWithString:options:</h3>
<p class="spaceabove">Returns a string containing characters the receiver and a given string have in common, starting from the beginning of each up to the first characters that aren’t equivalent.</p><p class="spaceabovemethod">- (NSString *)commonPrefixWithString:(NSString *)<em>aString</em> options:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringCompareOptions">NSStringCompareOptions</a>)<em>mask</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>aString</em></dt><dd><p>The string with which to compare the receiver.</p></dd><dt><em>mask</em></dt><dd><p>Options for the comparison. The following search options may be specified by combining them with the C bitwise <code>OR</code> operator: <code><a href="NSString.html#//apple_ref/doc/c_ref/NSCaseInsensitiveSearch">NSCaseInsensitiveSearch</a></code>, <code><a href="NSString.html#//apple_ref/doc/c_ref/NSLiteralSearch">NSLiteralSearch</a></code>. See <em><a href="../../../../../Conceptual/Strings/index.html#//apple_ref/doc/uid/10000035i" target="_top">String Programming Guide for Cocoa</a></em> for details on these options.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>A string containing characters the receiver and <em>aString</em> have in common, starting from the beginning of each up to the first characters that aren’t equivalent.</p></div>
<h5 class="tight">Discussion</h5><p>The returned string is based on the characters of the receiver. For example, if the receiver is “Ma¨dchen” and <em>aString</em> is “Mädchenschule”, the string returned is “Ma¨dchen”, not “Mädchen”. </p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/hasPrefix:">&#8211;&#xA0;hasPrefix:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/compare:" title="compare:"></a><a name="//apple_ref/doc/uid/20000154-compare_" title="compare:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_62"></a><h3 class="jump instanceMethod">compare:</h3>
<p class="spaceabove">Returns the result of invoking <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:range:">compare:options:range:</a></code> with no options and the receiver’s full extent as the range.</p><p class="spaceabovemethod">- (<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSComparisonResult" target="_top">NSComparisonResult</a>)compare:(NSString *)<em>aString</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>aString</em></dt><dd><p>The string with which to compare the receiver.</p><p>This value must not be <code>nil</code>. If this value is <code>nil</code>, the behavior is undefined and may change in future versions of Mac OS X.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>The result of invoking <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:range:">compare:options:range:</a></code> with no options and the receiver’s full extent as the range.</p></div> <h5 class="tight">Discussion</h5><p>If you are comparing strings to present to the end-user, you should typically use <code><a href="NSString.html#//apple_ref/occ/instm/NSString/localizedCompare:">localizedCompare:</a></code> or <code><a href="NSString.html#//apple_ref/occ/instm/NSString/localizedCaseInsensitiveCompare:">localizedCaseInsensitiveCompare:</a></code> instead.</p><div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability"><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/localizedCompare:">&#8211;&#xA0;localizedCompare:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/localizedCaseInsensitiveCompare:">&#8211;&#xA0;localizedCaseInsensitiveCompare:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:">&#8211;&#xA0;compare:options:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/caseInsensitiveCompare:">&#8211;&#xA0;caseInsensitiveCompare:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/isEqualToString:">&#8211;&#xA0;isEqualToString:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/compare:options:" title="compare:options:"></a><a name="//apple_ref/doc/uid/20000154-compare_options_" title="compare:options:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_63"></a>
<h3 class="jump instanceMethod">compare:options:</h3>
<p class="spaceabove">Returns the result of invoking <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:range:">compare:options:range:</a></code> with a given mask as the options and the receiver’s full extent as the range.</p><p class="spaceabovemethod">- (<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSComparisonResult" target="_top">NSComparisonResult</a>)compare:(NSString *)<em>aString</em> options:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringCompareOptions">NSStringCompareOptions</a>)<em>mask</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>aString</em></dt><dd><p>The string with which to compare the receiver. </p><p>This value must not be <code>nil</code>. If this value is <code>nil</code>, the behavior is undefined and may change in future versions of Mac OS X.</p></dd><dt><em>mask</em></dt><dd><p>Options for the search—you can combine any of the following using a C bitwise OR operator: <code><a href="NSString.html#//apple_ref/doc/c_ref/NSCaseInsensitiveSearch">NSCaseInsensitiveSearch</a></code>, <code><a href="NSString.html#//apple_ref/doc/c_ref/NSLiteralSearch">NSLiteralSearch</a></code>, <code><a href="NSString.html#//apple_ref/doc/c_ref/NSNumericSearch">NSNumericSearch</a></code>. See <em><a href="../../../../../Conceptual/Strings/index.html#//apple_ref/doc/uid/10000035i" target="_top">String Programming Guide for Cocoa</a></em> for details on these options.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>The result of invoking <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:range:">compare:options:range:</a></code> with a given mask as the options and the receiver’s full extent as the range. </p></div> <h5 class="tight">Discussion</h5><p>If you are comparing strings to present to the end-user, you should typically use <code><a href="NSString.html#//apple_ref/occ/instm/NSString/localizedCompare:">localizedCompare:</a></code> or <code><a href="NSString.html#//apple_ref/occ/instm/NSString/localizedCaseInsensitiveCompare:">localizedCaseInsensitiveCompare:</a></code> instead, or use <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:range:locale:">compare:options:range:locale:</a></code> and pass the user’s locale.</p><div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability"><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/localizedCompare:">&#8211;&#xA0;localizedCompare:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/localizedCaseInsensitiveCompare:">&#8211;&#xA0;localizedCaseInsensitiveCompare:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:range:locale:">&#8211;&#xA0;compare:options:range:locale:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/caseInsensitiveCompare:">&#8211;&#xA0;caseInsensitiveCompare:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/isEqualToString:">&#8211;&#xA0;isEqualToString:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/compare:options:range:" title="compare:options:range:"></a><a name="//apple_ref/doc/uid/20000154-compare_options_range_" title="compare:options:range:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_64"></a>
<h3 class="jump instanceMethod">compare:options:range:</h3>
<p class="spaceabove">Returns the result of invoking <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:range:locale:">compare:options:range:locale:</a></code> with a <code>nil</code> locale.</p><p class="spaceabovemethod">- (<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSComparisonResult" target="_top">NSComparisonResult</a>)compare:(NSString *)<em>aString</em> options:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringCompareOptions">NSStringCompareOptions</a>)<em>mask</em> range:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSRange" target="_top">NSRange</a>)<em>range</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>aString</em></dt><dd><p>The string with which to compare the range of the receiver specified by <em>range</em>. </p><p>This value must not be <code>nil</code>. If this value is <code>nil</code>, the behavior is undefined and may change in future versions of Mac OS X.</p></dd><dt><em>mask</em></dt><dd><p>Options for the search—you can combine any of the following using a C bitwise OR operator: <code><a href="NSString.html#//apple_ref/doc/c_ref/NSCaseInsensitiveSearch">NSCaseInsensitiveSearch</a></code>, <code><a href="NSString.html#//apple_ref/doc/c_ref/NSLiteralSearch">NSLiteralSearch</a></code>, <code><a href="NSString.html#//apple_ref/doc/c_ref/NSNumericSearch">NSNumericSearch</a></code>.</p><p>See <em><a href="../../../../../Conceptual/Strings/index.html#//apple_ref/doc/uid/10000035i" target="_top">String Programming Guide for Cocoa</a></em> for details on these options.</p></dd><dt><em>range</em></dt><dd><p>The range of the receiver over which to perform the comparison. The range must not exceed the bounds of the receiver.</p><div class="importantboxdef"><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_10" title="Important:"></a><p><strong>Important:</strong>&nbsp;Raises an <code><a href="../../../Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSRangeException" target="_top">NSRangeException</a></code> if <em>range</em> exceeds the bounds of the receiver.</p><p></p></div></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>The result of invoking <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:range:locale:">compare:options:range:locale:</a></code> with a <code>nil</code> locale.</p></div> <h5 class="tight">Discussion</h5><p>If you are comparing strings to present to the end-user, you should typically use <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:range:locale:">compare:options:range:locale:</a></code> instead and pass the user’s locale (<code><a href="../../NSLocale_Class/Reference/Reference.html#//apple_ref/occ/clm/NSLocale/currentLocale" target="_top">currentLocale</a></code> [<code>NSLocale</code>]).</p><div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability"><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/localizedCompare:">&#8211;&#xA0;localizedCompare:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/localizedCaseInsensitiveCompare:">&#8211;&#xA0;localizedCaseInsensitiveCompare:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:">&#8211;&#xA0;compare:options:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/caseInsensitiveCompare:">&#8211;&#xA0;caseInsensitiveCompare:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/isEqualToString:">&#8211;&#xA0;isEqualToString:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/compare:options:range:locale:" title="compare:options:range:locale:"></a><a name="//apple_ref/doc/uid/20000154-CJBIGJGD" title="compare:options:range:locale:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_65"></a><h3 class="jump instanceMethod">compare:options:range:locale:</h3>
<p class="spaceabove">Returns an <code>NSComparisonResult</code> value that indicates the lexical ordering of a specified range within the receiver and a given string.</p><p class="spaceabovemethod">- (<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSComparisonResult" target="_top">NSComparisonResult</a>)compare:(NSString *)<em>aString</em> options:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringCompareOptions">NSStringCompareOptions</a>)<em>mask</em> range:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSRange" target="_top">NSRange</a>)<em>range</em> locale:(id)<em>locale</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>aString</em></dt><dd><p>The string with which to compare the range of the receiver specified by <em>range</em>. </p><p>This value must not be <code>nil</code>. If this value is <code>nil</code>, the behavior is undefined and may change in future versions of Mac OS X.</p></dd><dt><em>mask</em></dt><dd><p>Options for the search—you can combine any of the following using a C bitwise OR operator: <code><a href="NSString.html#//apple_ref/doc/c_ref/NSCaseInsensitiveSearch">NSCaseInsensitiveSearch</a></code>, <code><a href="NSString.html#//apple_ref/doc/c_ref/NSLiteralSearch">NSLiteralSearch</a></code>, <code><a href="NSString.html#//apple_ref/doc/c_ref/NSNumericSearch">NSNumericSearch</a></code>.</p><p>See <em><a href="../../../../../Conceptual/Strings/index.html#//apple_ref/doc/uid/10000035i" target="_top">String Programming Guide for Cocoa</a></em> for details on these options.</p></dd><dt><em>range</em></dt><dd><p>The range of the receiver over which to perform the comparison. The range must not exceed the bounds of the receiver.</p><div class="importantboxdef"><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_11" title="Important:"></a><p><strong>Important:</strong>&nbsp;Raises an <code><a href="../../../Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSRangeException" target="_top">NSRangeException</a></code> if <em>range</em> exceeds the bounds of the receiver.</p><p></p></div></dd><dt><em>locale</em></dt><dd><p>An instance of <code>NSLocale</code>. If this value not <code>nil</code> and is not an instance of <code>NSLocale</code>, uses the current locale instead. If you are comparing strings to present to the end-user, you should typically pass the user’s locale (<code><a href="../../NSLocale_Class/Reference/Reference.html#//apple_ref/occ/clm/NSLocale/currentLocale" target="_top">currentLocale</a></code> [<code>NSLocale</code>]).</p><p>The locale argument affects both equality and ordering algorithms. For example, in some locales, accented characters are ordered immediately after the base; other locales order them after “z”.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p><code><a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSOrderedAscending" target="_top">NSOrderedAscending</a></code> if the substring of the receiver given by <em>range</em> precedes <em>aString</em> in lexical ordering for the locale given in <em>dict</em>, <code><a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSOrderedSame" target="_top">NSOrderedSame</a></code> if the substring of the receiver and <em>aString</em> are equivalent in lexical value, and <code><a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSOrderedDescending" target="_top">NSOrderedDescending</a></code> if the substring of the receiver follows <em>aString</em>. </p></div> <h5 class="tight">Special Considerations</h5><p>Prior to Mac OS X v10.5, the <em>locale</em> argument was an instance of <code>NSDictionary</code>. On Mac OS X v10.5 and later, if you pass an instance of <code>NSDictionary</code> the current locale is used instead.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability"><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/localizedCompare:">&#8211;&#xA0;localizedCompare:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/localizedCaseInsensitiveCompare:">&#8211;&#xA0;localizedCaseInsensitiveCompare:</a></code></li>
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/caseInsensitiveCompare:">&#8211;&#xA0;caseInsensitiveCompare:</a></code></li>
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:">&#8211;&#xA0;compare:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:">&#8211;&#xA0;compare:options:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:range:">&#8211;&#xA0;compare:options:range:</a></code></li>
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/isEqualToString:">&#8211;&#xA0;isEqualToString:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/completePathIntoString:caseSensitive:matchesIntoArray:filterTypes:" title="completePathIntoString:caseSensitive:matchesIntoArray:filterTypes:"></a><a name="//apple_ref/doc/uid/20000154-completePathIntoString_caseSensitive_matchesIntoArray_filterTypes_" title="completePathIntoString:caseSensitive:matchesIntoArray:filterTypes:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_66"></a>
<h3 class="jump instanceMethod">completePathIntoString:caseSensitive:matchesIntoArray:filterTypes:</h3>
<p class="spaceabove">Interprets the receiver as a path in the file system and attempts to perform filename completion, returning a numeric value that indicates whether a match was possible, and by reference the longest path that matches the receiver. </p><p class="spaceabovemethod">- (<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a>)completePathIntoString:(NSString **)<em>outputName</em> caseSensitive:(BOOL)<em>flag</em> matchesIntoArray:(<a href="../../NSArray_Class/NSArray.html#//apple_ref/doc/c_ref/NSArray" target="_top">NSArray</a> **)<em>outputArray</em> filterTypes:(<a href="../../NSArray_Class/NSArray.html#//apple_ref/doc/c_ref/NSArray" target="_top">NSArray</a> *)<em>filterTypes</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>outputName</em></dt><dd><p>Upon return, contains the longest path that matches the receiver.</p></dd><dt><em>flag</em></dt><dd><p>If <code>YES</code>, the methods considers case for possible completions.</p></dd><dt><em>outputArray</em></dt><dd><p>Upon return, contains all matching filenames. </p></dd><dt><em>filterTypes</em></dt><dd><p>An array of <code>NSString</code> objects specifying path extensions to consider for completion. only paths whose extensions (not including the extension separator) match one of those strings.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p><code>0</code> if no matches are found and <code>1</code> if exactly one match is found. In the case of multiple matches, returns the actual number of matching paths if <em>outputArray</em> is provided, or simply a positive value if <em>outputArray</em> is <code>NULL</code>. </p></div>
<h5 class="tight">Discussion</h5><p>You can check for the existence of matches without retrieving by passing <code>NULL</code> as <em>outputArray</em>.</p><p>Note that this method only works with file paths (not, for example, string representations of URLs). </p><div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSPathUtilities.h</code></div><a name="//apple_ref/occ/instm/NSString/componentsSeparatedByCharactersInSet:" title="componentsSeparatedByCharactersInSet:"></a><a name="//apple_ref/doc/uid/20000154-SW5" title="componentsSeparatedByCharactersInSet:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_67"></a><h3 class="jump instanceMethod">componentsSeparatedByCharactersInSet:</h3><p class="spaceabove">Returns an array containing substrings from the receiver that have been divided by characters in a given set.</p><p class="spaceabovemethod">- (<a href="../../NSArray_Class/NSArray.html#//apple_ref/doc/c_ref/NSArray" target="_top">NSArray</a> *)componentsSeparatedByCharactersInSet:(<a href="../../NSCharacterSet_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSCharacterSet" target="_top">NSCharacterSet</a> *)<em>separator</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>separator</em></dt><dd><p>A character set containing the characters to to use to split the receiver. Must not be <code>nil</code>.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>An <code>NSArray</code> object containing substrings from the receiver that have been divided by characters in <em>separator</em>.</p></div> <h5 class="tight">Discussion</h5><p>The substrings in the array appear in the order they did in the receiver. Adjacent occurrences of the separator characters produce empty strings in the result. Similarly, if the string begins or ends with separator characters, the first or last substring, respectively, is empty.</p><div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability"><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/componentsSeparatedByString:">&#8211;&#xA0;componentsSeparatedByString:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/stringByTrimmingCharactersInSet:">&#8211;&#xA0;stringByTrimmingCharactersInSet:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/componentsSeparatedByString:" title="componentsSeparatedByString:"></a><a name="//apple_ref/doc/uid/20000154-componentsSeparatedByString_" title="componentsSeparatedByString:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_68"></a><h3 class="jump instanceMethod">componentsSeparatedByString:</h3>
<p class="spaceabove">Returns an array containing substrings from the receiver that have been divided by a given separator.</p><p class="spaceabovemethod">- (<a href="../../NSArray_Class/NSArray.html#//apple_ref/doc/c_ref/NSArray" target="_top">NSArray</a> *)componentsSeparatedByString:(NSString *)<em>separator</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>separator</em></dt><dd><p>The separator string.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>An <code>NSArray</code> object containing substrings from the receiver that have been divided by <em>separator</em>.</p></div>
<h5 class="tight">Discussion</h5><p>The substrings in the array appear in the order they did in the receiver. Adjacent occurrences of the separator string produce empty strings in the result. Similarly, if the string begins or ends with the separator, the first or last substring, respectively, is empty. For example, this code fragment:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>NSString *list = @"Norman, Stanley, Fletcher";<span></span></pre></td></tr><tr><td scope="row"><pre>NSArray *listItems = [list componentsSeparatedByString:@", "];<span></span></pre></td></tr></table></div><p>produces an array <code>{ @"Norman", @"Stanley", @"Fletcher" }</code>.</p><p>If <em>list</em> begins with a comma and space—for example, <code>", Norman, Stanley, Fletcher"</code>—the array has these contents: <code>{ @"", @"Norman", @"Stanley", @"Fletcher" }</code></p><p>If <em>list</em> has no separators—for example, <code>"Norman"</code>—the array contains the string itself, in this case <code>{ @"Norman" }</code>.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="../../NSArray_Class/NSArray.html#//apple_ref/occ/instm/NSArray/componentsJoinedByString:" target="_top">componentsJoinedByString:</a></code> (<code>NSArray</code>)</li>
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/pathComponents">&#8211;&#xA0;pathComponents</a></code></li></ul><h5 class="tight">Related Sample Code</h5><ul class="availability"><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/MoveMe/index.html#//apple_ref/doc/uid/DTS40007315" target="_top">MoveMe</a></span></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/cStringUsingEncoding:" title="cStringUsingEncoding:"></a><a name="//apple_ref/doc/uid/20000154-BAJHJHHD" title="cStringUsingEncoding:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_71"></a><h3 class="jump instanceMethod">cStringUsingEncoding:</h3>
<p class="spaceabove">Returns a representation of the receiver as a C string using a given encoding.</p><p class="spaceabovemethod">- (const char *)cStringUsingEncoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)<em>encoding</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>encoding</em></dt><dd><p>The encoding for the returned C string.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>A C string representation of the receiver using the encoding specified by <em>encoding</em>. Returns <code>NULL</code> if the receiver cannot be losslessly converted to <em>encoding</em>.</p></div>
<h5 class="tight">Discussion</h5><p>The returned C string is guaranteed to be valid only until either the receiver is freed, or until the current autorelease pool is emptied, whichever occurs first. You should copy the C string or use <code><a href="NSString.html#//apple_ref/occ/instm/NSString/getCString:maxLength:encoding:">getCString:maxLength:encoding:</a></code> if it needs to store the C string beyond this time.</p><p>You can use <code><a href="NSString.html#//apple_ref/occ/instm/NSString/canBeConvertedToEncoding:">canBeConvertedToEncoding:</a></code> to check whether a string can be losslessly converted to <em>encoding</em>. If it can’t, you can use <code><a href="NSString.html#//apple_ref/occ/instm/NSString/dataUsingEncoding:allowLossyConversion:">dataUsingEncoding:allowLossyConversion:</a></code> to get a C-string representation using <em>encoding</em>, allowing some loss of information (note that the data returned by <code>dataUsingEncoding:allowLossyConversion:</code> is not a strict C-string since it does not have a <code>NULL</code> terminator).</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/canBeConvertedToEncoding:">&#8211;&#xA0;canBeConvertedToEncoding:</a></code></li>
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/defaultCStringEncoding">+&#xA0;defaultCStringEncoding</a></code></li>
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/UTF8String">&#8211;&#xA0;UTF8String</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/dataUsingEncoding:" title="dataUsingEncoding:"></a><a name="//apple_ref/doc/uid/20000154-dataUsingEncoding_" title="dataUsingEncoding:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_72"></a>
<h3 class="jump instanceMethod">dataUsingEncoding:</h3>
<p class="spaceabove">Returns an <code>NSData</code> object containing a representation of the receiver encoded using a given encoding.</p><p class="spaceabovemethod">- (<a href="../../NSData_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSData" target="_top">NSData</a> *)dataUsingEncoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)<em>encoding</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>encoding</em></dt><dd><p>A string encoding.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>The result of invoking <code><a href="NSString.html#//apple_ref/occ/instm/NSString/dataUsingEncoding:allowLossyConversion:">dataUsingEncoding:allowLossyConversion:</a></code> with <code>NO</code> as the second argument (that is, requiring lossless conversion).</p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">Related Sample Code</h5><ul class="availability"><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/GenericKeychain/index.html#//apple_ref/doc/uid/DTS40007797" target="_top">GenericKeychain</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/SimpleURLConnections/index.html#//apple_ref/doc/uid/DTS40009245" target="_top">SimpleURLConnections</a></span></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/dataUsingEncoding:allowLossyConversion:" title="dataUsingEncoding:allowLossyConversion:"></a><a name="//apple_ref/doc/uid/20000154-dataUsingEncoding_allowLossyConversion_" title="dataUsingEncoding:allowLossyConversion:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_73"></a>
<h3 class="jump instanceMethod">dataUsingEncoding:allowLossyConversion:</h3>
<p class="spaceabove">Returns an <code>NSData</code> object containing a representation of the receiver encoded using a given encoding.</p><p class="spaceabovemethod">- (<a href="../../NSData_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSData" target="_top">NSData</a> *)dataUsingEncoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)<em>encoding</em> allowLossyConversion:(BOOL)<em>flag</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>encoding</em></dt><dd><p>A string encoding.</p></dd><dt><em>flag</em></dt><dd><p>If <code>YES</code>, then allows characters to be removed or altered in conversion.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>An <code>NSData</code> object containing a representation of the receiver encoded using <em>encoding</em>. Returns <code><!--a -->nil<!--/a--></code> if <em>flag</em> is <code>NO</code> and the receiver can’t be converted without losing some information (such as accents or case).</p></div>
<h5 class="tight">Discussion</h5><p>If <em>flag</em> is <code>YES</code> and the receiver can’t be converted without losing some information, some characters may be removed or altered in conversion. For example, in converting a character from <code><a href="NSString.html#//apple_ref/doc/c_ref/NSUnicodeStringEncoding">NSUnicodeStringEncoding</a></code> to <code><a href="NSString.html#//apple_ref/doc/c_ref/NSASCIIStringEncoding">NSASCIIStringEncoding</a></code>, the character ‘Á’ becomes ‘A’, losing the accent.</p><p>This method creates an external representation (with a byte order marker, if necessary, to indicate endianness) to ensure that the resulting <code>NSData</code> object can be written out to a file safely. The result of this method, when lossless conversion is made, is the default “plain text” format for encoding and is the recommended way to save or transmit a string object.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/availableStringEncodings">+&#xA0;availableStringEncodings</a></code></li>
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/canBeConvertedToEncoding:">&#8211;&#xA0;canBeConvertedToEncoding:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/decomposedStringWithCanonicalMapping" title="decomposedStringWithCanonicalMapping"></a><a name="//apple_ref/doc/uid/20000154-CJBFHFAB" title="decomposedStringWithCanonicalMapping"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_74"></a><h3 class="jump instanceMethod">decomposedStringWithCanonicalMapping</h3>
<p class="spaceabove">Returns a string made by normalizing the receiver’s contents using Form D.</p><p class="spaceabovemethod">- (NSString *)decomposedStringWithCanonicalMapping</p><div class="return_value"><h5 class="tight">Return Value</h5><p>A string made by normalizing the receiver’s contents using the Unicode Normalization Form D.</p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/precomposedStringWithCanonicalMapping">&#8211;&#xA0;precomposedStringWithCanonicalMapping</a></code></li>
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/decomposedStringWithCompatibilityMapping">&#8211;&#xA0;decomposedStringWithCompatibilityMapping</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/decomposedStringWithCompatibilityMapping" title="decomposedStringWithCompatibilityMapping"></a><a name="//apple_ref/doc/uid/20000154-CJBCGAGB" title="decomposedStringWithCompatibilityMapping"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_75"></a><h3 class="jump instanceMethod">decomposedStringWithCompatibilityMapping</h3>
<p class="spaceabove">Returns a string made by normalizing the receiver’s contents using Form KD.</p><p class="spaceabovemethod">- (NSString *)decomposedStringWithCompatibilityMapping</p>
<div class="return_value"><h5 class="tight">Return Value</h5><p>A string made by normalizing the receiver’s contents using the Unicode Normalization Form KD.</p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/precomposedStringWithCompatibilityMapping">&#8211;&#xA0;precomposedStringWithCompatibilityMapping</a></code></li>
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/decomposedStringWithCanonicalMapping">&#8211;&#xA0;decomposedStringWithCanonicalMapping</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/description" title="description"></a><a name="//apple_ref/doc/uid/20000154-description" title="description"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_76"></a>
<h3 class="jump instanceMethod">description</h3><p class="spaceabove">Returns the receiver.</p><p class="spaceabovemethod">- (NSString *)description</p><div class="return_value"><h5 class="tight">Return Value</h5><p>The receiver.</p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/doubleValue" title="doubleValue"></a><a name="//apple_ref/doc/uid/20000154-doubleValue" title="doubleValue"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_77"></a>
<h3 class="jump instanceMethod">doubleValue</h3>
<p class="spaceabove">Returns the floating-point value of the receiver’s text as a <code>double</code>.</p><p class="spaceabovemethod">- (double)doubleValue</p><div class="return_value"><h5 class="tight">Return Value</h5><p>The floating-point value of the receiver’s text as a <code>double</code>. Returns <code><!--a -->HUGE_VAL<!--/a--></code> or <code><!--a -->–HUGE_VAL<!--/a--></code> on overflow, 0.0 on underflow. Returns <code>0.0</code> if the receiver doesn’t begin with a valid text representation of a floating-point number.</p></div>
<h5 class="tight">Discussion</h5><p>This method skips any whitespace at the beginning of the string. This method uses formatting information stored in the non-localized value; use an <code>NSScanner</code> object for localized scanning of numeric values from a string.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability"><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/floatValue">&#8211;&#xA0;floatValue</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/longLongValue">&#8211;&#xA0;longLongValue</a></code></li>
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/integerValue">&#8211;&#xA0;integerValue</a></code></li>
<li class="availability"> <code><a href="../../NSScanner_Class/Reference/Reference.html#//apple_ref/occ/instm/NSScanner/scanDouble:" target="_top">&#8211;&#xA0;scanDouble:</a></code> (<code>NSScanner</code>)</li></ul><h5 class="tight">Related Sample Code</h5><ul class="availability"><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/iPhoneUnitTests/index.html#//apple_ref/doc/uid/DTS40008868" target="_top">iPhoneUnitTests</a></span></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/fastestEncoding" title="fastestEncoding"></a><a name="//apple_ref/doc/uid/20000154-fastestEncoding" title="fastestEncoding"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_80"></a>
<h3 class="jump instanceMethod">fastestEncoding</h3>
<p class="spaceabove">Returns the fastest encoding to which the receiver may be converted without loss of information.</p><p class="spaceabovemethod">- (<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)fastestEncoding</p><div class="return_value"><h5 class="tight">Return Value</h5><p>The fastest encoding to which the receiver may be converted without loss of information.</p></div>
<h5 class="tight">Discussion</h5><p>“Fastest” applies to retrieval of characters from the string. This encoding may not be space efficient.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/smallestEncoding">&#8211;&#xA0;smallestEncoding</a></code></li>
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/getCharacters:range:">&#8211;&#xA0;getCharacters:range:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/fileSystemRepresentation" title="fileSystemRepresentation"></a><a name="//apple_ref/doc/uid/20000154-fileSystemRepresentation" title="fileSystemRepresentation"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_81"></a><h3 class="jump instanceMethod">fileSystemRepresentation</h3>
<p class="spaceabove">Returns a file system-specific representation of the receiver. </p><p class="spaceabovemethod">- (const char *)fileSystemRepresentation</p><div class="return_value"><h5 class="tight">Return Value</h5><p>A file system-specific representation of the receiver, as described for <code><a href="NSString.html#//apple_ref/occ/instm/NSString/getFileSystemRepresentation:maxLength:">getFileSystemRepresentation:maxLength:</a></code>.</p></div>
<h5 class="tight">Discussion</h5><p>The returned C string will be automatically freed just as a returned object would be released; your code should copy the representation or use <code><a href="NSString.html#//apple_ref/occ/instm/NSString/getFileSystemRepresentation:maxLength:">getFileSystemRepresentation:maxLength:</a></code> if it needs to store the representation outside of the autorelease context in which the representation is created.</p><p>Raises an <code><a href="NSString.html#//apple_ref/doc/c_ref/NSCharacterConversionException">NSCharacterConversionException</a></code> if the receiver can’t be represented in the file system’s encoding.</p><p>Note that this method only works with file paths (not, for example, string representations of URLs). </p><p>To convert a <code>char *</code> path (such as you might get from a C library routine) to an <code>NSString</code> object, use <code>NSFileManager</code>‘s <code><a href="../../NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/stringWithFileSystemRepresentation:length:" target="_top">stringWithFileSystemRepresentation:length:</a></code> method.</p><div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSPathUtilities.h</code></div><a name="//apple_ref/occ/instm/NSString/floatValue" title="floatValue"></a><a name="//apple_ref/doc/uid/20000154-floatValue" title="floatValue"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_82"></a>
<h3 class="jump instanceMethod">floatValue</h3>
<p class="spaceabove">Returns the floating-point value of the receiver’s text as a <code>float</code>.</p><p class="spaceabovemethod">- (float)floatValue</p><div class="return_value"><h5 class="tight">Return Value</h5><p>The floating-point value of the receiver’s text as a <code>float</code>, skipping whitespace at the beginning of the string. Returns <code><!--a -->HUGE_VAL<!--/a--></code> or <code><!--a -->–HUGE_VAL<!--/a--></code> on overflow, <code>0.0</code> on underflow. Also returns <code>0.0</code> if the receiver doesn’t begin with a valid text representation of a floating-point number.</p></div>
<h5 class="tight">Discussion</h5><p>This method uses formatting information stored in the non-localized value; use an <code>NSScanner</code> object for localized scanning of numeric values from a string.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/doubleValue">&#8211;&#xA0;doubleValue</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/longLongValue">&#8211;&#xA0;longLongValue</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/integerValue">&#8211;&#xA0;integerValue</a></code></li>
<li class="availability"> <code><a href="../../NSScanner_Class/Reference/Reference.html#//apple_ref/occ/instm/NSScanner/scanFloat:" target="_top">&#8211;&#xA0;scanFloat:</a></code> (<code>NSScanner</code>)</li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/getBytes:maxLength:usedLength:encoding:options:range:remainingRange:" title="getBytes:maxLength:usedLength:encoding:options:range:remainingRange:"></a><a name="//apple_ref/doc/uid/20000154-SW19" title="getBytes:maxLength:usedLength:encoding:options:range:remainingRange:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_83"></a><h3 class="jump instanceMethod">getBytes:maxLength:usedLength:encoding:options:range:remainingRange:</h3><p class="spaceabove">Gets a given range of characters as bytes in a specified encoding.</p><p class="spaceabovemethod">- (BOOL)getBytes:(void *)<em>buffer</em> maxLength:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a>)<em>maxBufferCount</em> usedLength:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a> *)<em>usedBufferCount</em> encoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)<em>encoding</em> options:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncodingConversionOptions">NSStringEncodingConversionOptions</a>)<em>options</em> range:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSRange" target="_top">NSRange</a>)<em>range</em> remainingRange:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSRangePointer" target="_top">NSRangePointer</a>)<em>leftover</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>buffer</em></dt><dd><p>A buffer into which to store the bytes from the receiver. The returned bytes are <em>not</em> <code>NULL</code>-terminated.</p></dd><dt><em>maxBufferCount</em></dt><dd><p>The maximum number of bytes to write to <em>buffer</em>.</p></dd><dt><em>usedBufferCount</em></dt><dd><p>The number of bytes used from <em>buffer</em>. Pass <code>NULL</code> if you do not need this value.</p></dd><dt><em>encoding</em></dt><dd><p>The encoding to use for the returned bytes.</p></dd><dt><em>options</em></dt><dd><p>A mask to specify options to use for converting the receiver’s contents to <em>encoding</em> (if conversion is necessary).</p></dd><dt><em>range</em></dt><dd><p>The range of characters in the receiver to get.</p></dd><dt><em>leftover</em></dt><dd><p>The remaining range. Pass <code>NULL</code> If you do not need this value.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p><code>YES</code> if some characters were converted, otherwise <code>NO</code>.</p></div> <h5 class="tight">Discussion</h5><p>Conversion might stop when the buffer fills, but it might also stop when the conversion isn't possible due to the chosen encoding.</p><div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/getCharacters:" title="getCharacters:"></a><a name="//apple_ref/doc/uid/20000154-getCharacters_" title="getCharacters:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_84"></a>
<h3 class="jump instanceMethod">getCharacters:</h3>
<p class="spaceabove">Copies all characters from the receiver into a given buffer.&#032;(<strong><font color="red">Deprecated.</font></strong>&#032;This method is unsafe because it could potentially cause buffer overruns. Use <code><a href="NSString.html#//apple_ref/occ/instm/NSString/getCharacters:range:">getCharacters:range:</a></code> instead.)</p><p class="spaceabovemethod">- (void)getCharacters:(<a href="NSString.html#//apple_ref/doc/c_ref/unichar">unichar</a> *)<em>buffer</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>buffer</em></dt><dd><p>Upon return, contains the characters from the receiver. <em>buffer</em> must be large enough to contain all characters in the string (<code>[string length]*sizeof(unichar)</code>).</p></dd></dl><h5 class="tight">Discussion</h5><p>Invokes <code><a href="NSString.html#//apple_ref/occ/instm/NSString/getCharacters:range:">getCharacters:range:</a></code> with <em>buffer</em> and the entire extent of the receiver as the range.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/length">&#8211;&#xA0;length</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/getCharacters:range:" title="getCharacters:range:"></a><a name="//apple_ref/doc/uid/20000154-getCharacters_range_" title="getCharacters:range:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_85"></a>
<h3 class="jump instanceMethod">getCharacters:range:</h3>
<p class="spaceabove">Copies characters from a given range in the receiver into a given buffer.</p><p class="spaceabovemethod">- (void)getCharacters:(<a href="NSString.html#//apple_ref/doc/c_ref/unichar">unichar</a> *)<em>buffer</em> range:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSRange" target="_top">NSRange</a>)<em>aRange</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>buffer</em></dt><dd><p>Upon return, contains the characters from the receiver. <em>buffer</em> must be large enough to contain the characters in the range <em>aRange</em> (<code>aRange.length*sizeof(unichar)</code>).</p></dd><dt><em>aRange</em></dt><dd><p>The range of characters to retrieve. The range must not exceed the bounds of the receiver.</p><div class="importantboxdef"><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_12" title="Important:"></a><p><strong>Important:</strong>&nbsp;Raises an <code><a href="../../../Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSRangeException" target="_top">NSRangeException</a></code> if any part of <em>aRange</em> lies beyond the bounds of the receiver.</p><p></p></div></dd></dl>
<h5 class="tight">Discussion</h5><p>This method does not add a <code>NULL</code> character. </p><p>The abstract implementation of this method uses <code><a href="NSString.html#//apple_ref/occ/instm/NSString/characterAtIndex:">characterAtIndex:</a></code> repeatedly, correctly extracting the characters, though very inefficiently. Subclasses should override it to provide a fast implementation.</p><div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/getCString:maxLength:encoding:" title="getCString:maxLength:encoding:"></a><a name="//apple_ref/doc/uid/20000154-BAJGIEIE" title="getCString:maxLength:encoding:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_88"></a><h3 class="jump instanceMethod">getCString:maxLength:encoding:</h3>
<p class="spaceabove">Converts the receiver’s content to a given encoding and stores them in a buffer.</p><p class="spaceabovemethod">- (BOOL)getCString:(char *)<em>buffer</em> maxLength:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a>)<em>maxBufferCount</em> encoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)<em>encoding</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>buffer</em></dt><dd><p>Upon return, contains the converted C-string plus the <code>NULL</code> termination byte. The buffer must include room for <em>maxBufferCount</em> bytes.</p></dd><dt><em>maxBufferCount</em></dt><dd><p>The maximum number of bytes in the string to return in buffer (<em>including</em> the <code>NULL</code> termination byte). </p></dd><dt><em>encoding</em></dt><dd><p>The encoding for the returned C string.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p><code>YES</code> if the operation was successful, otherwise <code>NO</code>. Returns <code>NO</code> if conversion is not possible due to encoding errors or if <em>buffer</em> is too small. </p></div>
<h5 class="tight">Discussion</h5><p>Note that in the treatment of the <em>maxBufferCount</em> argument, this method differs from the deprecated <span class="content_text">getCString:maxLength:</span> method which it replaces. (The buffer should include room for <em>maxBufferCount</em> bytes; this number should accommodate the expected size of the return value plus the <code>NULL</code> termination byte, which this method adds.)</p><p>You can use <code><a href="NSString.html#//apple_ref/occ/instm/NSString/canBeConvertedToEncoding:">canBeConvertedToEncoding:</a></code> to check whether a string can be losslessly converted to <em>encoding</em>. If it can’t, you can use <code><a href="NSString.html#//apple_ref/occ/instm/NSString/dataUsingEncoding:allowLossyConversion:">dataUsingEncoding:allowLossyConversion:</a></code> to get a C-string representation using <em>encoding</em>, allowing some loss of information (note that the data returned by <code>dataUsingEncoding:allowLossyConversion:</code> is not a strict C-string since it does not have a <code>NULL</code> terminator).</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/cStringUsingEncoding:">&#8211;&#xA0;cStringUsingEncoding:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/canBeConvertedToEncoding:">&#8211;&#xA0;canBeConvertedToEncoding:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/UTF8String">&#8211;&#xA0;UTF8String</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/getFileSystemRepresentation:maxLength:" title="getFileSystemRepresentation:maxLength:"></a><a name="//apple_ref/doc/uid/20000154-getFileSystemRepresentation_maxLength_" title="getFileSystemRepresentation:maxLength:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_90"></a>
<h3 class="jump instanceMethod">getFileSystemRepresentation:maxLength:</h3>
<p class="spaceabove">Interprets the receiver as a system-independent path and fills a buffer with a C-string in a format and encoding suitable for use with file-system calls.</p><p class="spaceabovemethod">- (BOOL)getFileSystemRepresentation:(char *)<em>buffer</em> maxLength:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a>)<em>maxLength</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>buffer</em></dt><dd><p>Upon return, contains a C-string that represent the receiver as as a system-independent path, plus the <code>NULL</code> termination byte. The size of <em>buffer</em> must be large enough to contain <em>maxLength</em> bytes. </p></dd><dt><em>maxLength</em></dt><dd><p>The maximum number of bytes in the string to return in <em>buffer</em> (including a terminating <code>NULL</code> character, which this method adds). </p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p><code>YES</code> if <em>buffer</em> is successfully filled with a file-system representation, otherwise <code>NO</code> (for example, if <em>maxLength</em> would be exceeded or if the receiver can’t be represented in the file system’s encoding).</p></div>
<h5 class="tight">Discussion</h5><p>This method operates by replacing the abstract path and extension separator characters (‘<code>/</code>’ and ‘<code>.</code>’ respectively) with their equivalents for the operating system. If the system-specific path or extension separator appears in the abstract representation, the characters it is converted to depend on the system (unless they’re identical to the abstract separators).</p><p>Note that this method only works with file paths (not, for example, string representations of URLs).</p><p>The following example illustrates the use of the <em>maxLength</em> argument. The first method invocation returns failure as the file representation of the string (<code>@"/mach_kernel"</code>) is 12 bytes long and the value passed as the <em>maxLength</em> argument (<code>12</code>) does not allow for the addition of a <code>NULL</code> termination byte.</p><div class="codesample clear"><table><tr><td scope="row"><pre>char filenameBuffer[13];<span></span></pre></td></tr><tr><td scope="row"><pre>BOOL success;<span></span></pre></td></tr><tr><td scope="row"><pre>success = [@"/mach_kernel" getFileSystemRepresentation:filenameBuffer maxLength:12];<span></span></pre></td></tr><tr><td scope="row"><pre>// success == NO<span></span></pre></td></tr><tr><td scope="row"><pre>// Changing the length to include the NULL character does work<span></span></pre></td></tr><tr><td scope="row"><pre>success = [@"/mach_kernel" getFileSystemRepresentation:filenameBuffer maxLength:13];<span></span></pre></td></tr><tr><td scope="row"><pre>// success == YES<span></span></pre></td></tr></table></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/fileSystemRepresentation">&#8211;&#xA0;fileSystemRepresentation</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSPathUtilities.h</code></div><a name="//apple_ref/occ/instm/NSString/getLineStart:end:contentsEnd:forRange:" title="getLineStart:end:contentsEnd:forRange:"></a><a name="//apple_ref/doc/uid/20000154-getLineStart_end_contentsEnd_forRange_" title="getLineStart:end:contentsEnd:forRange:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_91"></a>
<h3 class="jump instanceMethod">getLineStart:end:contentsEnd:forRange:</h3>
<p class="spaceabove">Returns by reference the beginning of the first line and the end of the last line touched by the given range.</p><p class="spaceabovemethod">- (void)getLineStart:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a> *)<em>startIndex</em> end:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a> *)<em>lineEndIndex</em> contentsEnd:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a> *)<em>contentsEndIndex</em> forRange:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSRange" target="_top">NSRange</a>)<em>aRange</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>startIndex</em></dt><dd><p>Upon return, contains the index of the first character of the line containing the beginning of <em>aRange</em>. Pass <code>NULL</code> if you do not need this value (in which case the work to compute the value isn’t performed).</p></dd><dt><em>lineEndIndex</em></dt><dd><p>Upon return, contains the index of the first character past the terminator of the line containing the end of <em>aRange</em>. Pass <code>NULL</code> if you do not need this value (in which case the work to compute the value isn’t performed).</p></dd><dt><em>contentsEndIndex</em></dt><dd><p>Upon return, contains the index of the first character of the terminator of the line containing the end of <em>aRange</em>. Pass <code>NULL</code> if you do not need this value (in which case the work to compute the value isn’t performed). </p></dd><dt><em>aRange</em></dt><dd><p>A range within the receiver. The value must not exceed the bounds of the receiver. </p><div class="importantboxdef"><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_13" title="Important:"></a><p><strong>Important:</strong>&nbsp;Raises an <code><a href="../../../Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSRangeException" target="_top">NSRangeException</a></code> if any part of <em>aRange</em> lies beyond the end of the string. </p><p></p></div></dd></dl>
<h5 class="tight">Discussion</h5><p>A line is delimited by any of these characters, the longest possible sequence being preferred to any shorter:</p><ul class="ul"><li class="li"><p><code>U+000D</code> (<code>\r</code> or <code>CR</code>)</p></li>
<li class="li"><p><code>U+2028</code> (Unicode line separator)</p></li>
<li class="li"><p><code>U+000A</code> (<code>\n</code> or <code>LF</code>)</p></li>
<li class="li"><p><code>U+2029</code> (Unicode paragraph separator)</p></li>
<li class="li"><p><code>\r\n</code>, in that order (also known as <code>CRLF</code>)</p></li></ul><p>If <em>aRange</em> is contained with a single line, of course, the returned indexes all belong to that line. You can use the results of this method to construct ranges for lines by using the start index as the range’s location and the difference between the end index and the start index as the range’s length.</p><p>This method detects all invalid ranges (including those with negative lengths). For applications linked against Mac OS X v10.6 and later, this error causes an exception; for applications linked against earlier releases, this error causes a warning, which is displayed just once per application execution.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/lineRangeForRange:">&#8211;&#xA0;lineRangeForRange:</a></code></li>
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/substringWithRange:">&#8211;&#xA0;substringWithRange:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/getParagraphStart:end:contentsEnd:forRange:" title="getParagraphStart:end:contentsEnd:forRange:"></a><a name="//apple_ref/doc/uid/20000154-BCIEEJED" title="getParagraphStart:end:contentsEnd:forRange:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_92"></a><h3 class="jump instanceMethod">getParagraphStart:end:contentsEnd:forRange:</h3>
<p class="spaceabove">Returns by reference the beginning of the first paragraph and the end of the last paragraph touched by the given range.</p><p class="spaceabovemethod">- (void)getParagraphStart:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a> *)<em>startIndex</em> end:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a> *)<em>endIndex</em> contentsEnd:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a> *)<em>contentsEndIndex</em> forRange:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSRange" target="_top">NSRange</a>)<em>aRange</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>startIndex</em></dt><dd><p>Upon return, contains the index of the first character of the paragraph containing the beginning of <em>aRange</em>. Pass <code>NULL</code> if you do not need this value (in which case the work to compute the value isn’t performed).</p></dd><dt><em>endIndex</em></dt><dd><p>Upon return, contains the index of the first character past the terminator of the paragraph containing the end of <em>aRange</em>. Pass <code>NULL</code> if you do not need this value (in which case the work to compute the value isn’t performed).</p></dd><dt><em>contentsEndIndex</em></dt><dd><p>Upon return, contains the index of the first character of the terminator of the paragraph containing the end of <em>aRange</em>. Pass <code>NULL</code> if you do not need this value (in which case the work to compute the value isn’t performed).</p></dd><dt><em>aRange</em></dt><dd><p>A range within the receiver. The value must not exceed the bounds of the receiver.</p></dd></dl>
<h5 class="tight">Discussion</h5><p>If <em>aRange</em> is contained with a single paragraph, of course, the returned indexes all belong to that paragraph. Similar to <code><a href="NSString.html#//apple_ref/occ/instm/NSString/getLineStart:end:contentsEnd:forRange:">getLineStart:end:contentsEnd:forRange:</a></code>, you can use the results of this method to construct the ranges for paragraphs.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/paragraphRangeForRange:">&#8211;&#xA0;paragraphRangeForRange:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/hash" title="hash"></a><a name="//apple_ref/doc/uid/20000154-hash" title="hash"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_93"></a><h3 class="jump instanceMethod">hash</h3>
<p class="spaceabove">Returns an unsigned integer that can be used as a hash table address.</p><p class="spaceabovemethod">- (<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a>)hash</p><div class="return_value"><h5 class="tight">Return Value</h5><p>An unsigned integer that can be used as a hash table address.</p></div>
<h5 class="tight">Discussion</h5><p>If two string objects are equal (as determined by the <code><a href="NSString.html#//apple_ref/occ/instm/NSString/isEqualToString:">isEqualToString:</a></code> method), they must have the same hash value. The abstract implementation of this method fulfills this requirement, so subclasses of <code>NSString</code> shouldn’t override it.</p><p>You should not rely on this method returning the same hash value across releases of Mac OS X.</p><div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">Related Sample Code</h5><ul class="availability"><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/GKTank/index.html#//apple_ref/doc/uid/DTS40008918" target="_top">GKTank</a></span></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/hasPrefix:" title="hasPrefix:"></a><a name="//apple_ref/doc/uid/20000154-hasPrefix_" title="hasPrefix:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_94"></a>
<h3 class="jump instanceMethod">hasPrefix:</h3>
<p class="spaceabove">Returns a Boolean value that indicates whether a given string matches the beginning characters of the receiver.</p><p class="spaceabovemethod">- (BOOL)hasPrefix:(NSString *)<em>aString</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>aString</em></dt><dd><p>A string.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p><code>YES</code> if <em>aString</em> matches the beginning characters of the receiver, otherwise <code>NO</code>. Returns <code>NO</code> if <em>aString</em> is empty.</p></div>
<h5 class="tight">Discussion</h5><p>This method is a convenience for comparing strings using the <code><a href="NSString.html#//apple_ref/doc/c_ref/NSAnchoredSearch">NSAnchoredSearch</a></code> option. See <em><a href="../../../../../Conceptual/Strings/index.html#//apple_ref/doc/uid/10000035i" target="_top">String Programming Guide for Cocoa</a></em> for more information.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/hasSuffix:">&#8211;&#xA0;hasSuffix:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:range:">&#8211;&#xA0;compare:options:range:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/hasSuffix:" title="hasSuffix:"></a><a name="//apple_ref/doc/uid/20000154-hasSuffix_" title="hasSuffix:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_95"></a>
<h3 class="jump instanceMethod">hasSuffix:</h3>
<p class="spaceabove">Returns a Boolean value that indicates whether a given string matches the ending characters of the receiver. </p><p class="spaceabovemethod">- (BOOL)hasSuffix:(NSString *)<em>aString</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>aString</em></dt><dd><p>A string.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p><code>YES</code> if <em>aString</em> matches the ending characters of the receiver, otherwise <code>NO</code>. Returns <code>NO</code> if <em>aString</em> is empty. </p></div>
<h5 class="tight">Discussion</h5><p>This method is a convenience for comparing strings using the <code><a href="NSString.html#//apple_ref/doc/c_ref/NSAnchoredSearch">NSAnchoredSearch</a></code> and <code><a href="NSString.html#//apple_ref/doc/c_ref/NSBackwardsSearch">NSBackwardsSearch</a></code> options. See <em><a href="../../../../../Conceptual/Strings/index.html#//apple_ref/doc/uid/10000035i" target="_top">String Programming Guide for Cocoa</a></em> for more information.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/hasPrefix:">&#8211;&#xA0;hasPrefix:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/compare:options:range:">&#8211;&#xA0;compare:options:range:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/init" title="init"></a><a name="//apple_ref/doc/uid/20000154-init" title="init"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_96"></a><h3 class="jump instanceMethod">init</h3>
<p class="spaceabove">Returns an initialized <code>NSString</code> object that contains no characters.</p><p class="spaceabovemethod">- (id)init</p>
<div class="return_value"><h5 class="tight">Return Value</h5><p>An initialized <code>NSString</code> object that contains no characters. The returned object may be different from the original receiver.</p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/string">+&#xA0;string</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/initWithBytes:length:encoding:" title="initWithBytes:length:encoding:"></a><a name="//apple_ref/doc/uid/20000154-BCIGDAHA" title="initWithBytes:length:encoding:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_97"></a><h3 class="jump instanceMethod">initWithBytes:length:encoding:</h3>
<p class="spaceabove">Returns an initialized <code>NSString</code> object containing a given number of bytes from a given buffer of bytes interpreted in a given encoding.</p><p class="spaceabovemethod">- (id)initWithBytes:(const void *)<em>bytes</em> length:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a>)<em>length</em> encoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)<em>encoding</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>bytes</em></dt><dd><p>A buffer of bytes interpreted in the encoding specified by <em>encoding</em>.</p></dd><dt><em>length</em></dt><dd><p>The number of bytes to use from <em>bytes</em>.</p></dd><dt><em>encoding</em></dt><dd><p>The character encoding applied to <em>bytes</em>.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>An initialized <code>NSString</code> object containing <em>length</em> bytes from <em>bytes</em> interpreted using the encoding <em>encoding</em>. The returned object may be different from the original receiver.</p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithBytesNoCopy:length:encoding:freeWhenDone:">&#8211;&#xA0;initWithBytesNoCopy:length:encoding:freeWhenDone:</a></code></li></ul><h5 class="tight">Related Sample Code</h5><ul class="availability"><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/GenericKeychain/index.html#//apple_ref/doc/uid/DTS40007797" target="_top">GenericKeychain</a></span></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/initWithBytesNoCopy:length:encoding:freeWhenDone:" title="initWithBytesNoCopy:length:encoding:freeWhenDone:"></a><a name="//apple_ref/doc/uid/20000154-BCIHDHHI" title="initWithBytesNoCopy:length:encoding:freeWhenDone:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_98"></a><h3 class="jump instanceMethod">initWithBytesNoCopy:length:encoding:freeWhenDone:</h3>
<p class="spaceabove">Returns an initialized <code>NSString</code> object that contains a given number of bytes from a given buffer of bytes interpreted in a given encoding, and optionally frees the buffer.</p><p class="spaceabovemethod">- (id)initWithBytesNoCopy:(void *)<em>bytes</em> length:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a>)<em>length</em> encoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)<em>encoding</em> freeWhenDone:(BOOL)<em>flag</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>bytes</em></dt><dd><p>A buffer of bytes interpreted in the encoding specified by <em>encoding</em>.</p></dd><dt><em>length</em></dt><dd><p>The number of bytes to use from <em>bytes</em>.</p></dd><dt><em>encoding</em></dt><dd><p>The character encoding of <em>bytes</em>.</p></dd><dt><em>flag</em></dt><dd><p>If <code>YES</code>, the receiver frees the memory when it no longer needs the data; if <code>NO</code> it won’t.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>An initialized <code>NSString</code> object containing <em>length</em> bytes from <em>bytes</em> interpreted using the encoding <em>encoding</em>. The returned object may be different from the original receiver.</p></div> <h5 class="tight">Special Considerations</h5><p>If an error occurs during the creation of the string, then <em>bytes</em> is not freed even if <em>flag</em> is <code>YES</code>. In this case, the caller is responsible for freeing the buffer. This allows the caller to continue trying to create a string with the buffer, without having the buffer deallocated.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithBytes:length:encoding:">&#8211;&#xA0;initWithBytes:length:encoding:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/initWithCharacters:length:" title="initWithCharacters:length:"></a><a name="//apple_ref/doc/uid/20000154-initWithCharacters_length_" title="initWithCharacters:length:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_99"></a><h3 class="jump instanceMethod">initWithCharacters:length:</h3><p class="spaceabove">Returns an initialized <code>NSString</code> object that contains a given number of characters from a given C array of Unicode characters.</p><p class="spaceabovemethod">- (id)initWithCharacters:(const <a href="NSString.html#//apple_ref/doc/c_ref/unichar">unichar</a> *)<em>characters</em> length:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a>)<em>length</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>characters</em></dt><dd><p>A C array of Unicode characters; the value must not be <code>NULL</code>.</p><div class="importantboxdef"><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_14" title="Important:"></a><p><strong>Important:</strong>&nbsp;Raises an exception if <em>characters</em> is <code>NULL</code>, even if <em>length</em> is <code>0</code>.</p><p></p></div></dd><dt><em>length</em></dt><dd><p>The number of characters to use from <em>characters</em>.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>An initialized <code>NSString</code> object containing <em>length</em> characters taken from <em>characters</em>. The returned object may be different from the original receiver.</p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithCharacters:length:">+&#xA0;stringWithCharacters:length:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/initWithCharactersNoCopy:length:freeWhenDone:" title="initWithCharactersNoCopy:length:freeWhenDone:"></a><a name="//apple_ref/doc/uid/20000154-initWithCharactersNoCopy_length_freeWhenDone_" title="initWithCharactersNoCopy:length:freeWhenDone:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_100"></a>
<h3 class="jump instanceMethod">initWithCharactersNoCopy:length:freeWhenDone:</h3><p class="spaceabove">Returns an initialized <code>NSString</code> object that contains a given number of characters from a given C array of Unicode characters.</p><p class="spaceabovemethod">- (id)initWithCharactersNoCopy:(<a href="NSString.html#//apple_ref/doc/c_ref/unichar">unichar</a> *)<em>characters</em> length:(<a href="../../../Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSUInteger" target="_top">NSUInteger</a>)<em>length</em> freeWhenDone:(BOOL)<em>flag</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>characters</em></dt><dd><p>A C array of Unicode characters.</p></dd><dt><em>length</em></dt><dd><p>The number of characters to use from <em>characters</em>.</p></dd><dt><em>flag</em></dt><dd><p>If <code>YES</code>, the receiver will free the memory when it no longer needs the characters; if <code>NO</code> it won’t.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>An initialized <code>NSString</code> object that contains <em>length</em> characters from <em>characters</em>. The returned object may be different from the original receiver.</p></div> <h5 class="tight">Special Considerations</h5><p>If an error occurs during the creation of the string, then <em>bytes</em> is not freed even if <em>flag</em> is <code>YES</code>. In this case, the caller is responsible for freeing the buffer. This allows the caller to continue trying to create a string with the buffer, without having the buffer deallocated.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithCharacters:length:">+&#xA0;stringWithCharacters:length:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/initWithContentsOfFile:encoding:error:" title="initWithContentsOfFile:encoding:error:"></a><a name="//apple_ref/doc/uid/20000154-BAJHHCFJ" title="initWithContentsOfFile:encoding:error:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_102"></a><h3 class="jump instanceMethod">initWithContentsOfFile:encoding:error:</h3>
<p class="spaceabove">Returns an <code>NSString</code> object initialized by reading data from the file at a given path using a given encoding.</p><p class="spaceabovemethod">- (id)initWithContentsOfFile:(NSString *)<em>path</em> encoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)<em>enc</em> error:(<a href="../../NSError_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSError" target="_top">NSError</a> **)<em>error</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>path</em></dt><dd><p>A path to a file.</p></dd><dt><em>enc</em></dt><dd><p>The encoding of the file at <em>path</em>.</p></dd><dt><em>error</em></dt><dd><p>If an error occurs, upon return contains an <code>NSError</code> object that describes the problem. If you are not interested in possible errors, pass in <code>NULL</code>.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>An <code>NSString</code> object initialized by reading data from the file named by <em>path</em> using the encoding, <em>enc</em>. The returned object may be different from the original receiver. If the file can’t be opened or there is an encoding error, returns <code>nil</code>.</p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithContentsOfFile:encoding:error:">+&#xA0;stringWithContentsOfFile:encoding:error:</a></code></li>
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithContentsOfFile:usedEncoding:error:">&#8211;&#xA0;initWithContentsOfFile:usedEncoding:error:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/initWithContentsOfFile:usedEncoding:error:" title="initWithContentsOfFile:usedEncoding:error:"></a><a name="//apple_ref/doc/uid/20000154-BAJJEBAF" title="initWithContentsOfFile:usedEncoding:error:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_103"></a><h3 class="jump instanceMethod">initWithContentsOfFile:usedEncoding:error:</h3>
<p class="spaceabove">Returns an <code>NSString</code> object initialized by reading data from the file at a given path and returns by reference the encoding used to interpret the characters. </p><p class="spaceabovemethod">- (id)initWithContentsOfFile:(NSString *)<em>path</em> usedEncoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a> *)<em>enc</em> error:(<a href="../../NSError_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSError" target="_top">NSError</a> **)<em>error</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>path</em></dt><dd><p>A path to a file.</p></dd><dt><em>enc</em></dt><dd><p>Upon return, if the file is read successfully, contains the encoding used to interpret the file at <em>path</em>.</p></dd><dt><em>error</em></dt><dd><p>If an error occurs, upon returns contains an <code>NSError</code> object that describes the problem. If you are not interested in possible errors, pass in <code>NULL</code>.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>An <code>NSString</code> object initialized by reading data from the file named by <em>path</em>. The returned object may be different from the original receiver. If the file can’t be opened or there is an encoding error, returns <code>nil</code>.</p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithContentsOfFile:encoding:error:">+&#xA0;stringWithContentsOfFile:encoding:error:</a></code></li>
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithContentsOfFile:encoding:error:">&#8211;&#xA0;initWithContentsOfFile:encoding:error:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/initWithContentsOfURL:encoding:error:" title="initWithContentsOfURL:encoding:error:"></a><a name="//apple_ref/doc/uid/20000154-BAJGJHJG" title="initWithContentsOfURL:encoding:error:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_105"></a><h3 class="jump instanceMethod">initWithContentsOfURL:encoding:error:</h3>
<p class="spaceabove">Returns an <code>NSString</code> object initialized by reading data from a given URL interpreted using a given encoding. </p><p class="spaceabovemethod">- (id)initWithContentsOfURL:(<a href="../../NSURL_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSURL" target="_top">NSURL</a> *)<em>url</em> encoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)<em>enc</em> error:(<a href="../../NSError_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSError" target="_top">NSError</a> **)<em>error</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>url</em></dt><dd><p>The URL to read.</p></dd><dt><em>enc</em></dt><dd><p>The encoding of the file at <em>path</em>.</p></dd><dt><em>error</em></dt><dd><p>If an error occurs, upon returns contains an <code>NSError</code> object that describes the problem. If you are not interested in possible errors, pass in <code>NULL</code>.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>An <code>NSString</code> object initialized by reading data from <em>url</em>. The returned object may be different from the original receiver. If the URL can’t be opened or there is an encoding error, returns <code>nil</code>.</p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithContentsOfURL:encoding:error:">+&#xA0;stringWithContentsOfURL:encoding:error:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/initWithContentsOfURL:usedEncoding:error:" title="initWithContentsOfURL:usedEncoding:error:"></a><a name="//apple_ref/doc/uid/20000154-BAJCHFHC" title="initWithContentsOfURL:usedEncoding:error:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_106"></a><h3 class="jump instanceMethod">initWithContentsOfURL:usedEncoding:error:</h3>
<p class="spaceabove">Returns an <code>NSString</code> object initialized by reading data from a given URL and returns by reference the encoding used to interpret the data. </p><p class="spaceabovemethod">- (id)initWithContentsOfURL:(<a href="../../NSURL_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSURL" target="_top">NSURL</a> *)<em>url</em> usedEncoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a> *)<em>enc</em> error:(<a href="../../NSError_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSError" target="_top">NSError</a> **)<em>error</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>url</em></dt><dd><p>The URL from which to read data.</p></dd><dt><em>enc</em></dt><dd><p>Upon return, if <em>url</em> is read successfully, contains the encoding used to interpret the data.</p></dd><dt><em>error</em></dt><dd><p>If an error occurs, upon returns contains an <code>NSError</code> object that describes the problem. If you are not interested in possible errors, pass in <code>NULL</code>.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>An <code>NSString</code> object initialized by reading data from <em>url</em>. If <em>url</em> can’t be opened or the encoding cannot be determined, returns <code>nil</code>. The returned initialized object might be different from the original receiver </p></div>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithContentsOfURL:usedEncoding:error:">+&#xA0;stringWithContentsOfURL:usedEncoding:error:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/initWithCString:encoding:" title="initWithCString:encoding:"></a><a name="//apple_ref/doc/uid/20000154-BAJIGJAG" title="initWithCString:encoding:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_108"></a><h3 class="jump instanceMethod">initWithCString:encoding:</h3>
<p class="spaceabove">Returns an <code>NSString</code> object initialized using the characters in a given C array, interpreted according to a given encoding. </p><p class="spaceabovemethod">- (id)initWithCString:(const char *)<em>nullTerminatedCString</em> encoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)<em>encoding</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>nullTerminatedCString</em></dt><dd><p>A C array of characters. The array must end with a <code>NULL</code> character; intermediate <code>NULL</code> characters are not allowed.</p></dd><dt><em>encoding</em></dt><dd><p>The encoding of <em>nullTerminatedCString</em>.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>An <code>NSString</code> object initialized using the characters from <em>nullTerminatedCString</em>. The returned object may be different from the original receiver</p></div> <h5 class="tight">Discussion</h5><p>If <em>nullTerminatedCString</em> is not a <code>NULL</code>-terminated C string, or <em>encoding</em> does not match the actual encoding, the results are undefined.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/defaultCStringEncoding">+&#xA0;defaultCStringEncoding</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/initWithData:encoding:" title="initWithData:encoding:"></a><a name="//apple_ref/doc/uid/20000154-initWithData_encoding_" title="initWithData:encoding:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_111"></a>
<h3 class="jump instanceMethod">initWithData:encoding:</h3>
<p class="spaceabove">Returns an <code>NSString</code> object initialized by converting given data into Unicode characters using a given encoding.</p><p class="spaceabovemethod">- (id)initWithData:(<a href="../../NSData_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSData" target="_top">NSData</a> *)<em>data</em> encoding:(<a href="NSString.html#//apple_ref/doc/c_ref/NSStringEncoding">NSStringEncoding</a>)<em>encoding</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>data</em></dt><dd><p>An <code>NSData</code> object containing bytes in <em>encoding</em> and the default plain text format (that is, pure content with no attributes or other markups) for that encoding.</p></dd><dt><em>encoding</em></dt><dd><p>The encoding used by <em>data</em>.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>An <code>NSString</code> object initialized by converting the bytes in <em>data</em> into Unicode characters using <em>encoding</em>. The returned object may be different from the original receiver. Returns <code>nil</code> if the initialization fails for some reason (for example if <em>data</em> does not represent valid data for <em>encoding</em>).</p></div> <div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">Related Sample Code</h5><ul class="availability"><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/BonjourWeb/index.html#//apple_ref/doc/uid/DTS40007415" target="_top">BonjourWeb</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/TopSongs/index.html#//apple_ref/doc/uid/DTS40008925" target="_top">TopSongs</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/TransWeb/index.html#//apple_ref/doc/uid/DTS40008614" target="_top">TransWeb</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/XMLPerformance/index.html#//apple_ref/doc/uid/DTS40008094" target="_top">XMLPerformance</a></span></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/initWithFormat:" title="initWithFormat:"></a><a name="//apple_ref/doc/uid/20000154-initWithFormat_" title="initWithFormat:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_112"></a>
<h3 class="jump instanceMethod">initWithFormat:</h3><p class="spaceabove">Returns an <em>NSString</em> object initialized by using a given format string as a template into which the remaining argument values are substituted.</p><p class="spaceabovemethod">- (id)initWithFormat:(NSString *)<em>format</em> <em>...</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>format</em></dt><dd><p>A format string. See <span class="content_text"><a href="../../../../../Conceptual/Strings/Articles/FormatStrings.html#//apple_ref/doc/uid/20000943" target="_top">Formatting String Objects</a></span> for examples of how to use this method, and <span class="content_text"><a href="../../../../../Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265" target="_top">String Format Specifiers</a></span> for a list of format specifiers. This value must not be <code>nil</code>.</p><div class="importantboxdef"><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_15" title="Important:"></a><p><strong>Important:</strong>&nbsp;Raises an <code><a href="../../../Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSInvalidArgumentException" target="_top">NSInvalidArgumentException</a></code> if <em>format</em> is <code>nil</code>.</p><p></p></div></dd><dt><em>...</em></dt><dd><p>A comma-separated list of arguments to substitute into <em>format</em>. </p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>An <em>NSString</em> object initialized by using <em>format</em> as a template into which the remaining argument values are substituted according to the canonical locale. The returned object may be different from the original receiver.</p></div> <h5 class="tight">Discussion</h5><p>Invokes <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithFormat:locale:arguments:">initWithFormat:locale:arguments:</a></code> with <code>nil</code> as the locale, hence using the canonical locale to format numbers. This is useful, for example, if you want to produce "non-localized" formatting which needs to be written out to files and parsed back later.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability"><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithFormat:">+&#xA0;stringWithFormat:</a></code></li><li class="availability"> <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithFormat:locale:arguments:">&#8211;&#xA0;initWithFormat:locale:arguments:</a></code></li></ul><h5 class="tight">Related Sample Code</h5><ul class="availability"><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/AQOfflineRenderTest/index.html#//apple_ref/doc/uid/DTS40008413" target="_top">AQOfflineRenderTest</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/BonjourWeb/index.html#//apple_ref/doc/uid/DTS40007415" target="_top">BonjourWeb</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/iPhoneExtAudioFileConvertTest/index.html#//apple_ref/doc/uid/DTS40009222" target="_top">iPhoneExtAudioFileConvertTest</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/SpeakHere/index.html#//apple_ref/doc/uid/DTS40007802" target="_top">SpeakHere</a></span></li><li class="availability"> <span class="content_text"><a href="../../../../../../../samplecode/TableViewSuite/index.html#//apple_ref/doc/uid/DTS40007318" target="_top">TableViewSuite</a></span></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/initWithFormat:arguments:" title="initWithFormat:arguments:"></a><a name="//apple_ref/doc/uid/20000154-initWithFormat_arguments_" title="initWithFormat:arguments:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_113"></a><h3 class="jump instanceMethod">initWithFormat:arguments:</h3>
<p class="spaceabove">Returns an <em>NSString</em> object initialized by using a given format string as a template into which the remaining argument values are substituted according to the user’s default locale.</p><p class="spaceabovemethod">- (id)initWithFormat:(NSString *)<em>format</em> arguments:(va_list)<em>argList</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>format</em></dt><dd><p>A format string. See <span class="content_text"><a href="../../../../../Conceptual/Strings/Articles/FormatStrings.html#//apple_ref/doc/uid/20000943" target="_top">Formatting String Objects</a></span> for examples of how to use this method, and <span class="content_text"><a href="../../../../../Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265" target="_top">String Format Specifiers</a></span> for a list of format specifiers. This value must not be <code>nil</code>.</p><div class="importantboxdef"><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_16" title="Important:"></a><p><strong>Important:</strong>&nbsp;Raises an <code><a href="../../../Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSInvalidArgumentException" target="_top">NSInvalidArgumentException</a></code> if <em>format</em> is <code>nil</code>.</p><p></p></div></dd><dt><em>argList</em></dt><dd><p>A list of arguments to substitute into <em>format</em>.</p></dd></dl><div class="return_value"><h5 class="tight">Return Value</h5><p>An <em>NSString</em> object initialized by using <em>format</em> as a template into which the values in <em>argList</em> are substituted according to the user’s default locale. The returned object may be different from the original receiver.</p></div>
<h5 class="tight">Discussion</h5><p>Invokes <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithFormat:locale:arguments:">initWithFormat:locale:arguments:</a></code> with <code><!--a -->nil<!--/a--></code> as the locale.</p>
<div class="Availability"><h5 class="tight">Availability</h5><ul class="availability"><li class="availability">Available in iPhone OS 2.0 and later.</li></ul></div><h5 class="tight">See Also</h5><ul class="availability">
<li class="availability"> <code><a href="NSString.html#//apple_ref/occ/clm/NSString/stringWithFormat:">+&#xA0;stringWithFormat:</a></code></li></ul><div class="DeclaredIn"><h5 class="tight">Declared In</h5><code class="HeaderFile">NSString.h</code></div><a name="//apple_ref/occ/instm/NSString/initWithFormat:locale:" title="initWithFormat:locale:"></a><a name="//apple_ref/doc/uid/20000154-initWithFormat_locale_" title="initWithFormat:locale:"></a><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_114"></a>
<h3 class="jump instanceMethod">initWithFormat:locale:</h3>
<p class="spaceabove">Returns an <em>NSString</em> object initialized by using a given format string as a template into which the remaining argument values are substituted according to given locale information.</p><p class="spaceabovemethod">- (id)initWithFormat:(NSString *)<em>format</em> locale:(id)<em>locale</em> <em>...</em></p><h5 class="tight">Parameters</h5><dl class="termdef"><dt><em>format</em></dt><dd><p>A format string. See <span class="content_text"><a href="../../../../../Conceptual/Strings/Articles/FormatStrings.html#//apple_ref/doc/uid/20000943" target="_top">Formatting String Objects</a></span> for examples of how to use this method, and <span class="content_text"><a href="../../../../../Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265" target="_top">String Format Specifiers</a></span> for a list of format specifiers. This value must not be <code>nil</code>.</p><div class="importantboxdef"><a name="//apple_ref/doc/uid/20000154-DontLinkElementID_17" title="Important:"></a><p><strong>Important:</strong>&nbsp;Raises an <code><a href="../../../Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSInvalidArgumentException" target="_top">NSInvalidArgumentException</a></code> if <em>format</em> is <code>nil</code>.</p><p></p></div></dd><dt><em>locale</em></dt><dd><p>This may be an instance of <code>NSDictionary</code> containing locale information or an instance of <code>NSLocale</code>. If this value is <code>nil</code>, uses the canonical locale. </p><p>To use a dictionary containing the current user's locale, you can use <code>[[NSUserDefaults standardUserDefaults] dictionaryRepresentation]</code>.</p></dd><dt><em>...</em></dt><dd><p>A comma-separated list of arguments to substitute into <em>format</em>.</p></dd></dl>
<h5 class="tight">Discussion</h5><p>Invokes <code><a href="NSString.html#//apple_ref/occ/instm/NSString/initWithFormat:locale:arguments:">initWithFormat:locale:arguments:</a></code> with <em>locale</em> as the locale.</p>