![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/share/doc/gnustep-base-doc/Base/Reference/ |
Upload File : |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>NSFormatter class reference</title> </head> <body> <font face="serif"> <a href="Base.html">Up</a> <br /> <h1><a name="title$NSFormatter">NSFormatter class reference</a></h1> <h3>Authors</h3> <dl> <dt>Richard Frith-Macdonald (<a href="mailto:richard@brainstorm.co.uk"><code>richard@brainstorm.co.uk</code></a>)</dt> <dd> </dd> </dl> <p><b>Copyright:</b> (C) 1998 Free Software Foundation, Inc.</p> <div> </div> <h1><a name="001000000000"> Software documentation for the NSFormatter class </a></h1> <h2><a name="class$NSFormatter">NSFormatter</a> : <a rel="gsdoc" href="NSObject.html#class$NSObject">NSObject</a></h2> <blockquote class="declared"> <dl> <dt><b>Declared in:</b></dt> <dd>Foundation/NSFormatter.h</dd> </dl> </blockquote> <blockquote> <dl> <dt><b>Conforms to:</b></dt> <dd><a rel="gsdoc" href="NSObject.html#protocol$(NSCopying)">NSCopying</a></dd> <dd><a rel="gsdoc" href="NSObject.html#protocol$(NSCoding)">NSCoding</a></dd> </dl> </blockquote> <div class="availability"> <b>Availability:</b> MacOS-X 10.0.0</div> <br /> <div class="desc"> This abstract class defines the interface for classes that support conversion between strings and objects of various types. GNUstep provides two concrete implementations of this class: <a rel="gsdoc" href="NSDateFormatter.html#class$NSDateFormatter">NSDateFormatter</a> and <a rel="gsdoc" href="NSNumberFormatter.html#class$NSNumberFormatter">NSNumberFormatter</a> . Others may be implemented for specialized applications. </div> <b>Method summary</b> <ul> <li><a rel="gsdoc" href="NSFormatter.html#method$NSFormatter-attributedStringForObjectValue$withDefaultAttributes$">-attributedStringForObjectValue:withDefaultAttributes:</a></li> <li><a rel="gsdoc" href="NSFormatter.html#method$NSFormatter-editingStringForObjectValue$">-editingStringForObjectValue:</a></li> <li><a rel="gsdoc" href="NSFormatter.html#method$NSFormatter-getObjectValue$forString$errorDescription$">-getObjectValue:forString:errorDescription:</a></li> <li><a rel="gsdoc" href="NSFormatter.html#method$NSFormatter-isPartialStringValid$newEditingString$errorDescription$">-isPartialStringValid:newEditingString:errorDescription:</a></li> <li><a rel="gsdoc" href="NSFormatter.html#method$NSFormatter-isPartialStringValid$proposedSelectedRange$originalString$originalSelectedRange$errorDescription$">-isPartialStringValid:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:</a></li> <li><a rel="gsdoc" href="NSFormatter.html#method$NSFormatter-stringForObjectValue$">-stringForObjectValue:</a></li> </ul> <hr width="50%" align="left" /> <div class="method"> <h3><a name="method$NSFormatter-attributedStringForObjectValue$withDefaultAttributes$">attributedStringForObjectValue: withDefaultAttributes: </a></h3> - (<a rel="gsdoc" href="NSAttributedString.html#class$NSAttributedString">NSAttributedString</a>*) <b>attributedStringForObjectValue:</b> (id)anObject<b> withDefaultAttributes:</b> (<a rel="gsdoc" href="NSDictionary.html#class$NSDictionary">NSDictionary</a>*)attr;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.0.0</div> <br /> <div class="desc"> This method calls <a rel="gsdoc" href="#method$NSFormatter-stringForObjectValue$"> [-stringForObjectValue:] </a> then marks up the string with attributes if it should be displayed specially. For example, in an application you may want to display out-of-range dates or numbers in italics. This is an optional method and may return <code>nil</code> to indicate that an attributed string is not provided. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSFormatter-editingStringForObjectValue$">editingStringForObjectValue: </a></h3> - (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*) <b>editingStringForObjectValue:</b> (id)anObject;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.0.0</div> <br /> <div class="desc"> For use in applications where user interactively edits a string. If the version of the string for editing purposes should look different from the string displayed (returned by <a rel="gsdoc" href="#method$NSFormatter-stringForObjectValue$"> [-stringForObjectValue:] </a> or <a rel="gsdoc" href="#method$NSFormatter-attributedStringForObjectValue$withDefaultAttributes$">-attributedStringForObjectValue:withDefaultAttributes:</a> ), return that here. For example, the edited string may contain formatting codes or similar that are not displayed in the final string. The default implementation simply returns <a rel="gsdoc" href="#method$NSFormatter-stringForObjectValue$">-stringForObjectValue:</a> . </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSFormatter-getObjectValue$forString$errorDescription$">getObjectValue: forString: errorDescription: </a></h3> - (BOOL) <b>getObjectValue:</b> (id*)anObject<b> forString:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)string<b> errorDescription:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>**)error;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.0.0</div> <br /> Subclasses <strong>must</strong> override this method.<br /> <div class="desc"> Primary method for converting a <var>string</var> to an object through parsing. <var>anObject</var> and <var>error</var> are output parameters; you should allocate memory for one pointer each for the variables passed into these methods. The returned object will have been created through <code>alloc-init</code>. If there is a problem with conversion, a constant-string description of what went wrong is returned through <var>error</var>, and <code>NO</code> is returned, otherwise <code>YES</code>. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSFormatter-isPartialStringValid$newEditingString$errorDescription$">isPartialStringValid: newEditingString: errorDescription: </a></h3> - (BOOL) <b>isPartialStringValid:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)partialString<b> newEditingString:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>**)newString<b> errorDescription:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>**)error;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.0.0</div> <br /> <div class="desc"> Checks whether <var>partialString</var> <em>could</em>, if it were completed, be parsed into a valid object. <var>newString</var> and <var>error</var> are output parameters; you should allocate memory for one pointer each for the variables passed into these methods. This method is set up to be called after every keystroke during user editing. If it returns <code>NO</code>, it optionally returns <var>newString</var> to replace what the user was editing; if it doesn't, the editor should delete the last character the user typed. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSFormatter-isPartialStringValid$proposedSelectedRange$originalString$originalSelectedRange$errorDescription$">isPartialStringValid: proposedSelectedRange: originalString: originalSelectedRange: errorDescription: </a></h3> - (BOOL) <b>isPartialStringValid:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>**)partialStringPtr<b> proposedSelectedRange:</b> (<a rel="gsdoc" href="TypesAndConstants.html#type$NSRange">NSRange</a>*)proposedSelRangePtr<b> originalString:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)origString<b> originalSelectedRange:</b> (<a rel="gsdoc" href="TypesAndConstants.html#type$NSRange">NSRange</a>)originalSelRangePtr<b> errorDescription:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>**)error;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.0.0</div> <br /> <div class="desc"> Checks whether a change to a string leaves it a valid string that, if it were completed, could be parsed into a valid object. <var>origString</var> contains the string before the proposed change, and origSelRange contains the range that is updated in the proposed change. <var>partialStringPtr</var> contains the new string to validate and <var>proposedSelRangePtr</var> holds the selection range that will be used if the string is accepted or replaced. Basically, this method returns <code>YES</code> if <var>partialStringPtr</var> is valid, otherwise <code>NO</code> and may replace <var>partialStringPtr</var> and proposedSelectedRange with improved values, and may report the reason in <var>error</var>. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSFormatter-stringForObjectValue$">stringForObjectValue: </a></h3> - (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*) <b>stringForObjectValue:</b> (id)anObject;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.0.0</div> <br /> Subclasses <strong>must</strong> override this method.<br /> <div class="desc"> Primary method for converting an object to a string through formatting. Object will be converted to string according to the formatter's implementation and init parameters. There is no default handling if the class of <var>anObject</var> is not what the formatter expects, and usually <code>nil</code> will be returned in this case. </div> <hr width="25%" align="left" /> </div> <br /> <a href="Base.html">Up</a> </font> </body> </html>