Undocumented NSString API

  • I just discovered a bunch of quite useful (or at least useful sounding) but
    unfortunately undocumented NSString methods. May we expect some of these
    methods to become part of the official API one day, or do we have to
    reinvent the wheel?

    Best Regards, Norbert

    _____________________________________________
    Norbert Heger, Objective Development
    http://www.obdev.at/

    @interface NSString (Undocumented)

    - (BOOL)isCanonical;
    - (BOOL)isCaseInsensitiveLike:(id)object;
    - (BOOL)isLike:(id)object;
    - (BOOL)matchesPattern:(id)aPattern;
    - (BOOL)matchesPattern:(id)aPattern caseInsensitive:(BOOL)flag;

    - (id)mutableSubstringFromRange:(NSRange)aRange;

    - (NSRange)significantText;

    - (NSString *)stringByAddingPercentEscapes;
    - (NSString *)stringByConvertingPathToURL;
    - (NSString *)stringByConvertingURLToPath;
    - (NSString *)stringByRemovingPercentEscapes;
    - (NSString *)stringWithoutAmpersand;

    - (NSString *)canonicalString;
    - (NSString *)displayableString;
    - (NSString *)quotedStringRepresentation;

    - (NSString *)standardizedNativePath;
    - (NSString *)standardizedURLPath;
    - (NSString *)urlPathByAppendingComponent:(NSString *)component;
    - (NSString *)urlPathByDeletingLastComponent;
    - (NSString *)urlPathRelativeToPath:(NSString *)path;

    - (NSString *)lowercaseStringWithLanguage:(NSString *)aLanguage;
    - (NSString *)uppercaseStringWithLanguage:(NSString *)language;
    - (NSString *)capitalizedStringWithLanguage:(NSString *)language;

    - (NSRange)_rangeOfPrefixFittingWidth:(float)width withFont:(NSFont *)font;
    - (NSRange)_rangeOfSuffixFittingWidth:(float)width withFont:(NSFont *)font;
    - (NSRange)_rangeOfSuffixFittingWidth:(float)width
        withAttributes:(id)attributes;
    - (NSRange)_rangeOfPrefixFittingWidth:(float)width
        withAttributes:(id)attributes;
    - (unsigned int)_endOfParagraphAtIndex:(unsigned int)anIndex;

    - (BOOL)_getFSRefForApplicationName:(FSRef *)ref;
    - (BOOL)_getFSRefForPath:(FSRef *)ref;
    - (BOOL)_getFSRefForServiceName:(FSRef *)ref;
    - (BOOL)_getFSSpecForPath:(FSSpec *)spec;
    - (BOOL)_getVRefNumForPath:(short *)vref;
    + (NSString *)_pathForFSRef:(FSRef *)ref;

    @end

    @interface NSMutableString (Undocumented)

    - (void)_deleteAllCharactersFromSet:(NSSet *)aSet;

    - (void)_replaceAllAppearancesOfString:(NSString *)aString
        withString:(NSString *)aString;

    - (void)_replaceFirstAppearanceOfString:(NSString *)aString
        withString:(NSString *)aString;

    - (void)_replaceLastAppearanceOfString:(NSString *)aString
        withString:(NSString *)aString;

    - (void)appendCString:(const char *)aString length:(int)aLength;

    - (void)appendCharacter:(unsigned short)aCharacter;

    - (void)appendCharacters:(const unsigned short *)characters
        length:(int)aLength;

    - (void)deleteLastCharacter;

    - (void)insertString:(NSString *)aString atIndex:(unsigned int)anIndex;

    - (void)replaceCharactersInRange:(NSRange)aRange
        withCString:(const char *)cString length:(unsigned int)length;

    - (void)replaceCharactersInRange:(NSRange)aRange
        withCharacters:(const unsigned short *)characters
        length:(unsigned int)length;

    - (void)trimWhitespace;

    @end
  • In general, these routines are not documented because they aren't in the
    public headers.  They aren't in the public headers because they aren't
    public API.  Private API will always exist; it consists of half-baked
    routines, routines that work in perhaps only a few internally-known cases
    (or fail in only a few internally known cases), experimental routines that
    are attempts at functionality but the API isn't solidified yet yet, etc.
    Some private API may eventually become public API, and will be documented at
    that time.  Most of it will remain private.

    We encourage developers not to use private API like this, because there is a
    good chance that the routines will change names, behaviors, etc. in future
    OS versions (breaking your programs), and we may not bother to tell you
    about it because they are, well, private - reserved for Apple's own use.  If
    there is specific functionality that you would like (besides making all our
    private API public), feel free to file a bug report and send feedback to
    <cocoa-feedback...>.

    Regards,

    Matthew

    --

    Matthew Formica
    DTS Engineer - Developer Tools and Cocoa
    Apple Computer, Inc.
    <mformica...>

    Mac OS X Development Tools:
        http://developer.apple.com/tools/
    Project Builder on the web:
        http://developer.apple.com/tools/projectbuilder/
    Project Builder FAQ:
        http://developer.apple.com/tools/projectbuilder/faq.html
    Cocoa docs on the web:
        http://developer.apple.com/techpubs/macosx/Cocoa/CocoaTopics.html
    Cocoa sample code:
        http://developer.apple.com/samplecode/Sample_Code/Cocoa.htm

    on 10/16/01 2:04 PM, Norbert Heger at <heger...> remarked:

    > I just discovered a bunch of quite useful (or at least useful sounding) but
    > unfortunately undocumented NSString methods. May we expect some of these
    > methods to become part of the official API one day, or do we have to
    > reinvent the wheel?
    >
    > Best Regards, Norbert
    >
    > _____________________________________________
    > Norbert Heger, Objective Development
    > http://www.obdev.at/
    >
    >
    >
    >
    >
    > @interface NSString (Undocumented)
    >
    > - (BOOL)isCanonical;
    > - (BOOL)isCaseInsensitiveLike:(id)object;
    > - (BOOL)isLike:(id)object;
    > - (BOOL)matchesPattern:(id)aPattern;
    > - (BOOL)matchesPattern:(id)aPattern caseInsensitive:(BOOL)flag;
    >
    > - (id)mutableSubstringFromRange:(NSRange)aRange;
    >
    > - (NSRange)significantText;
    >
    > - (NSString *)stringByAddingPercentEscapes;
    > - (NSString *)stringByConvertingPathToURL;
    > - (NSString *)stringByConvertingURLToPath;
    > - (NSString *)stringByRemovingPercentEscapes;
    > - (NSString *)stringWithoutAmpersand;
    >
    > - (NSString *)canonicalString;
    > - (NSString *)displayableString;
    > - (NSString *)quotedStringRepresentation;
    >
    > - (NSString *)standardizedNativePath;
    > - (NSString *)standardizedURLPath;
    > - (NSString *)urlPathByAppendingComponent:(NSString *)component;
    > - (NSString *)urlPathByDeletingLastComponent;
    > - (NSString *)urlPathRelativeToPath:(NSString *)path;
    >
    > - (NSString *)lowercaseStringWithLanguage:(NSString *)aLanguage;
    > - (NSString *)uppercaseStringWithLanguage:(NSString *)language;
    > - (NSString *)capitalizedStringWithLanguage:(NSString *)language;
    >
    >
    > - (NSRange)_rangeOfPrefixFittingWidth:(float)width withFont:(NSFont *)font;
    > - (NSRange)_rangeOfSuffixFittingWidth:(float)width withFont:(NSFont *)font;
    > - (NSRange)_rangeOfSuffixFittingWidth:(float)width
    > withAttributes:(id)attributes;
    > - (NSRange)_rangeOfPrefixFittingWidth:(float)width
    > withAttributes:(id)attributes;
    > - (unsigned int)_endOfParagraphAtIndex:(unsigned int)anIndex;
    >
    >
    > - (BOOL)_getFSRefForApplicationName:(FSRef *)ref;
    > - (BOOL)_getFSRefForPath:(FSRef *)ref;
    > - (BOOL)_getFSRefForServiceName:(FSRef *)ref;
    > - (BOOL)_getFSSpecForPath:(FSSpec *)spec;
    > - (BOOL)_getVRefNumForPath:(short *)vref;
    > + (NSString *)_pathForFSRef:(FSRef *)ref;
    >
    > @end
    >
    >
    >
    > @interface NSMutableString (Undocumented)
    >
    > - (void)_deleteAllCharactersFromSet:(NSSet *)aSet;
    >
    > - (void)_replaceAllAppearancesOfString:(NSString *)aString
    > withString:(NSString *)aString;
    >
    > - (void)_replaceFirstAppearanceOfString:(NSString *)aString
    > withString:(NSString *)aString;
    >
    > - (void)_replaceLastAppearanceOfString:(NSString *)aString
    > withString:(NSString *)aString;
    >
    > - (void)appendCString:(const char *)aString length:(int)aLength;
    >
    > - (void)appendCharacter:(unsigned short)aCharacter;
    >
    > - (void)appendCharacters:(const unsigned short *)characters
    > length:(int)aLength;
    >
    > - (void)deleteLastCharacter;
    >
    > - (void)insertString:(NSString *)aString atIndex:(unsigned int)anIndex;
    >
    > - (void)replaceCharactersInRange:(NSRange)aRange
    > withCString:(const char *)cString length:(unsigned int)length;
    >
    > - (void)replaceCharactersInRange:(NSRange)aRange
    > withCharacters:(const unsigned short *)characters
    > length:(unsigned int)length;
    >
    > - (void)trimWhitespace;
    >
    > @end
    > _______________________________________________
    > cocoa-dev mailing list
    > <cocoa-dev...>
    > http://www.lists.apple.com/mailman/listinfo/cocoa-dev
previous month october 2001 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today