NSArray Additions
Cluster 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.
NSArray
Inherits From:
NSObject
Declared in: EOControl/EOQualifier.h
EOControl/EOSortOrdering.h
EOControl/EOClassDescription.h
EOControl/EOKeyValueCoding.h
Enterprise Objects Framework adds two methods to the Foundation Framework's NSArray class, for filtering objects according to an EOQualifier and sorting them according to a series of EOSortOrderings.
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
.
See also: - valueForKey: , - computeCountForKey: , - computeMaxForKey: , - computeMinForKey: , - computeSumForKey:
computeCountForKey:
- (id)computeCountForKey:
(NSString *)key
Returns the number of elements in the receiver as an NSNumber; the argument key is ignored.
See also: - valueForKey: , - computeAvgForKey: , - computeMaxForKey: , - computeMinForKey: , - computeSumForKey:
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
.
See also: - valueForKey: , - computeAvgForKey: , - computeCountForKey: , - computeMinForKey: , - computeSumForKey:
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.
See also: - valueForKey: ,- computeAvgForKey: , - computeCountForKey: , - computeMaxForKey: , - computeMinForKey: , - computeSumForKey:
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)
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 compute
NameForKey:
.
See also: - computeAvgForKey: , - computeCountForKey: , - computeMaxForKey: , - computeMinForKey: , - computeSumForKey:
NSMutableArray
Inherits From:
NSObject
Declared in: EOControl/EOSortOrdering.h
NSMutableArray has one added method for sorting its elements according to a series of EOSortOrderings.
sortUsingKeyOrderArray:
- (void)sortUsingKeyOrderArray: (NSArray *)orderings
Sorts 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: - sortedArrayUsingKeyOrderArray: (NSArray)
Copyright © 1998, Apple Computer, Inc. All rights reserved.