Documentation Archive Developer
Search
PATH  Documentation > WebObjects 4.5 > EOControl Reference

Table of Contents

NSArray Additions


Category of: NSArray
Declared in:
EOControl/EOQualifier.h
EOControl/EOSortOrdering.h
EOControl/EOClassDescription.h
EOControl/EOKeyValueCoding.h




Category Description


Enterprise Objects Framework adds some methods to the Foundation Framework's NSArray class cluster, for filtering objects according to an EOQualifier and sorting them according to a series of EOSortOrderings. It also adds methods for key-value coding, with special support for aggregates, and a convenience method for filtering an array with a specified qualifier.




Method Types


Filtering and sorting objects
- filteredArrayUsingQualifier:
- sortedArrayUsingKeyOrderArray:
Aggregate functions
- computeAvgForKey:
- computeCountForKey:
- computeMaxForKey:
- computeMinForKey:
- computeSumForKey:
Key Value Coding
- valueForKey:
Making copies
- shallowCopy


Instance Methods



computeAvgForKey:

- (id)computeAvgForKey:(NSString *)key

Returns as an NSDecimalNumber the average of the values the receiver's objects have for key. If the array is empty, returns nil.

computeCountForKey:

- (id)computeCountForKey:(NSString *)key

Returns the number of elements in the receiver as an NSNumber; the argument key is ignored.

computeMaxForKey:

- (id)computeMaxForKey:(NSString *)key

Returns the value for key that is the highest for all of the objects in the receiver. If the array is empty, returns nil.

computeMinForKey:

- (id)computeMinForKey:(NSString *)key

Returns the object in the receiver that has the lowest value for key. If the array is empty, returns nil.

See Also: - valueForKey:, - computeAvgForKey:, - computeCountForKey:, - computeMaxForKey:, - computeSumForKey:



computeSumForKey:

- (id)computeSumForKey:(NSString *)key

Returns as an NSDecimalNumber the sum of the values the receiver's objects have for key.

filteredArrayUsingQualifier:

- (NSArray *)filteredArrayUsingQualifier:(EOQualifier *)aQualifier

Returns a new NSArray that contains only the objects from the receiver matching aQualifier.

shallowCopy

- (NSArray *)shallowCopy

Returns an NSArray that represents a shallow copy of the receiver. Used by Enterprise Objects Framework to snapshot to-many relationship properties.

sortedArrayUsingKeyOrderArray:

- (NSArray *)sortedArrayUsingKeyOrderArray:(NSArray *)orderings

Creates and returns a new NSArray by sorting the objects of the receiver according to the EOSortOrderings in orderings. The objects are compared by extracting the sort properties using the added NSObject method valueForKey: and sending them compare: messages.

See Also: - sortUsingKeyOrderArray: ( NSMutableArray Additions)



valueForKey:

- (id)valueForKey:(NSString *)key

When passed a "normal" key, returns an array composed of the results of sending valueForKey: to all elements of the array. When passed a key prefixed with "@", returns a single value that is the result of invoking an aggregate function on the values of the array.

For instance, if this method were passed the key @sum.budget, it would invoke computeSumForKey:@"budget" on the array, which would add the values for the budget keys for all of the objects in the array. The returned value would be the sum of all of the objects' budgets. The following aggregates are defined: @sum, @count, @avg, @min, @max. You can extend this set by adding methods to NSArray of the form computeNameForKey:.




Table of Contents