diff --git a/Cocoa/Categories/NGSCategories.h b/Cocoa/Categories/NGSCategories.h index 5fd05ea..61138a8 100644 --- a/Cocoa/Categories/NGSCategories.h +++ b/Cocoa/Categories/NGSCategories.h @@ -1,10 +1,15 @@ #import +/*! +@header +@abstract Numerous small category methods on Foundation and AppKit classes. +@author Nicholas Shanks +*/ + @interface NSArray (NGSIndexExtensions) /*! @method subarrayWithIndicies: -@author Nicholas Shanks -@created January 2004 +@updated January 2004 @abstract Returns an immutable array of the objects at the given indicies. */ - (NSArray *)subarrayWithIndicies:(NSIndexSet *)indicies; @@ -13,24 +18,21 @@ @interface NSArray (NGSKeyValueExtensions) /*! @method indexOfFirstObjectReturningValue:forKey: -@author Nicholas Shanks -@created January 2003 +@updated January 2003 @discussion Calls valueForKey: on each object in the array, returning the index of the first one encountered which itself returned the value passed in, according to isEqual:, or returns NSNotFound if no object matched for the given key/value pair. Mostly useful just for increasing code readability, as the methd is only one line long, but one that's not easy to understand at first glance. -@change NGS 2005-02-23: Removed unnecessary code, indexOfObject: already returns NSNotFound for me. +@updated 2005-02-23 NGS: Removed unnecessary code, indexOfObject: already returns NSNotFound for me. */ - (int)indexOfFirstObjectReturningValue:(id)value forKey:(id)key; /*! @method firstObjectReturningValue:forKey: -@author Nicholas Shanks -@created January 2003 +@updated January 2003 @discussion Calls valueForKey: on each object in the array, returning the first one encountered which itself returned the value passed in, according to isEqual:. Returns nil if no matching object is found. -@change NGS 2005-02-23: Removed message to indexOfFirstObjectReturningValue:forKey:, incorperated that method's code into this one. +@updated 2005-02-23 NGS: Removed message to indexOfFirstObjectReturningValue:forKey:, incorperated that method's code into this one. */ - (id)firstObjectReturningValue:(id)value forKey:(id)key; /*! @method objectsReturningValue:forKey: -@author Nicholas Shanks -@created January 2003 +@updated January 2003 @abstract Returns an array containing all objects in the receiver which have value set for key key. @discussion Calls valueForKey: on each object in the array, returning a new array containing all objects which themselves returned the value passed in, according to isEqual:. If no objects matched, this method returns an empty array. */ @@ -42,16 +44,15 @@ #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4 /*! @method newlineCharacterSet -@author Nicholas Shanks -@created March 2005 -@abstract Returns a character set containing only the newline and nextline characters (U+000AÐU+000D, U+0085). +@updated March 2005 +@abstract Returns a character set containing only the newline and nextline characters (U+000A–U+000D, U+0085). +@availability In 10.4 and above, this method is available from the OS. */ + (NSCharacterSet *)newlineCharacterSet; #endif /*! @method tabCharacterSet -@author Nicholas Shanks -@created March 2005 +@updated March 2005 @abstract Returns a character set containing only the horizontal and vertical tab characters (U+0009, U+000B). */ + (NSCharacterSet *)tabCharacterSet; @@ -78,20 +79,17 @@ @interface NSNumber (NGSRangeExtensions) /*! @method isWithinRange: -@author Nicholas Shanks -@created February 2003 +@updated February 2003 */ - (BOOL)isWithinRange:(NSRange)range; // location <= self <= location+length /*! @method isExclusivelyWithinRange: -@author Nicholas Shanks -@created February 2003 +@updated February 2003 */ - (BOOL)isExclusivelyWithinRange:(NSRange)range; // location < self < location+length /*! @method isBoundedByRange: -@author Nicholas Shanks -@created February 2003 +@updated February 2003 */ - (BOOL)isBoundedByRange:(NSRange)range; // location <= self < location+length @end @@ -99,15 +97,13 @@ @interface NSString (NGSFSSpecExtensions) /*! @method createFSRef -@author Nicholas Shanks -@created November 2002 +@updated November 2002 @abstract Returns an FSRef for the absolute path represented by the receiver. The caller is responsible for disposing of the FSRef. */ - (FSRef *)createFSRef; /*! @method createFSSpec -@author Nicholas Shanks -@created November 2002 +@updated November 2002 @abstract Returns an FSSpec for the absolute path represented by the receiver. The caller is responsible for disposing of the FSSpec. */ - (FSSpec *)createFSSpec; @@ -117,15 +113,14 @@ #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4 /*! @method boolValue -@author Nicholas Shanks -@created March 2001 +@updated March 2001 +@availability In 10.4 and above, this method is available from the OS. */ - (BOOL)boolValue; #endif /*! @method stringWithBool: -@author Nicholas Shanks -@created March 2001 +@updated March 2001 */ + (NSString *)stringWithBool:(BOOL)boolean; @end @@ -133,35 +128,43 @@ #pragma mark - #import +#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED +/* +@interface NSMatrix (NGSSelectionIndicies) +- (NSIndexSet *)selectedRows; +- (NSIndexSet *)selectedColumns; +@end +*/ +#endif + @interface NSOutlineView (NGSSelectedItemExtensions) /*! @method selectedItem -@author Nicholas Shanks -@created September 2001 +@updated September 2001 */ - (id)selectedItem; /*! @method selectedItems -@author Nicholas Shanks -@created September 2001 +@updated September 2001 */ - (NSArray *)selectedItems; @end -/* +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + @interface NSGradient (NGSGradientExtensions) /*! @method aquaGradient @method aquaGradientWithAlpha: @method gradientWithAlpha: -@author Nicholas Shanks -@created May 2007 -* / +@updated May 2007 +*/ + (NSGradient *)aquaGradient; + (NSGradient *)aquaGradientWithAlpha:(CGFloat)alpha; - (NSGradient *)gradientWithAlpha:(CGFloat)alpha; @end -*/ + +#endif #pragma mark - #import diff --git a/Cocoa/Categories/NGSCategories.m b/Cocoa/Categories/NGSCategories.m index 68eaffc..a9b3f36 100644 --- a/Cocoa/Categories/NGSCategories.m +++ b/Cocoa/Categories/NGSCategories.m @@ -171,6 +171,8 @@ @end #pragma mark - + +#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED /* @implementation NSMatrix (NGSSelectionIndicies) - (NSIndexSet *)selectedRows @@ -196,6 +198,8 @@ } @end */ +#endif + @implementation NSOutlineView (NGSSelectedItemExtensions) - (id)selectedItem { @@ -214,7 +218,9 @@ @end #pragma mark - -/* + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + @implementation NSGradient (NGSGradientExtensions) + (NSGradient *)aquaGradient { @@ -249,7 +255,9 @@ return [gradient autorelease]; } @end -*/ + +#endif + #pragma mark - /* CGLContext access for pre-10.3 */