COCollection class documentation

COCollection : COObject <ETCollection, ETCollectionMutation>

COCollection is a abstract class that provides a common API to various concrete collection subclasses such as COGroup or COContainer.

AuthorsGenerated by qmathe
Declared inCOCollection.h


COCollection represents a mutable collection, but subclasses can be immutable.

The collection content is stored in the property returned by -contentKey .

COCollection adopts the collection protocols. Which means you can mutate COCollection subclass instances using ETCollectionMutation methods such as -addObject: , -insertObject:atIndex: , -removeObject:atIndex: , -removeObject: etc. In addition, the class provides -addObjects: .

Every time the collection is mutated, COCollection posts a ETSourceDidUpdateNotification (in addition the usual Key-Value-Observing notifications).

If you override ETCollectionMutation primitive methods in a COCollection subclass, you must call -didUpdate in the new implementation (to ensure ETSourceDidUpdateNotification is posted).


+ (ETPropertyDescription *) contentPropertyDescriptionWithName: (NSString *)aName type: (NSString *)aType opposite: (NSString *)oppositeType

Returns a multivalued, ordered and persistent property.

You can use this method to easily describe your collection content in a way that matches the superclass contraints. The returned property can be customized, then inserted into the entity built with +newEntityDescription in your subclass. Name and type must not be nil.

Both type and opposite must be entity description names such as Anonymous.NSObject or NSObject.

The Anonymous prefix is optional. Most entity description names don't require a prefix, because they don't belong to a package description but are just registered at runtime directly, and belong to this Anonymous package as a result.

Can be overriden to change the constraints applying to the property.

    - (ETUTI *) objectType

    Returns UTI type for the collection elements.

    For inserting a new object in the collection, you can use this method to know the object class to instantiate.

    The returned UTI depends on -[ETPropertyDescription type] for the content property description (looked up using -contentKey).

    To customize the type, you must edit the receiver entity description.

    See also -[ETController currentObjectType] in EtoileUI.

      - (BOOL) isOrdered

      Returns whether the collection is ordered.

      The returned value is controlled by -[ETPropertyDescription isOrdered] for the content property description (looked up using -contentKey).

        Content Access

        - (NSString *) contentKey

        Returns the property name that holds the collection content.

        This method is used by COCollection to implement ETCollection and ETCollectionMutation protocol methods. Subclasses must thereby return a valid key, other the collection API won't behave correctly.

        For example, -[ETCollectionMutation insertObjects:atIndexes:hints:] implementation uses the content key to retrieve the content collection.

        By default, returns objects.

          Collection Mutation Additions

          - (void) addObjects: (NSArray *)anArray

          Adds all the given objects to the receiver content.

            - (void) didUpdate

            Posts ETSourceDidUpdateNotification.

            You must invoke this method every time the collection is changed. For example, when you override -[ETCollectionMutation insertObjects:atIndexes:hints:] .

            EtoileUI relies on this notification to reload the UI transparently.

              Object Matching

              - (id) objectForIdentifier: (NSString *)anId

              Returns the first object whose identifier matches.

              The search is shallow, in other words limited to the objects in the receiver content.

              See -[COObject identifier] .

                - (NSArray *) objectsMatchingQuery: (COQuery *)aQuery

                See -[COObjectMatching objectsMatchingQuery:] .

                Object graph traversal implementation for COObjectMatching protocol.