Instance Method

registerClass:forCellWithReuseIdentifier:

Register a class for use in creating new collection view cells.

Declaration

- (void)registerClass:(Class)cellClass forCellWithReuseIdentifier:(NSString *)identifier;

Parameters

cellClass

The class of a cell that you want to use in the collection view.

identifier

The reuse identifier to associate with the specified class. This parameter must not be nil and must not be an empty string.

Discussion

Prior to calling the dequeueReusableCellWithReuseIdentifier:forIndexPath: method of the collection view, you must use this method or the registerNib:forCellWithReuseIdentifier: method to tell the collection view how to create a new cell of the given type. If a cell of the specified type is not currently in a reuse queue, the collection view uses the provided information to create a new cell object automatically.

If you previously registered a class or nib file with the same reuse identifier, the class you specify in the cellClass parameter replaces the old entry. You may specify nil for cellClass if you want to unregister the class from the specified reuse identifier.

See Also

Creating Collection View Cells

- registerNib:forCellWithReuseIdentifier:

Register a nib file for use in creating new collection view cells.

- registerClass:forSupplementaryViewOfKind:withReuseIdentifier:

Registers a class for use in creating supplementary views for the collection view.

- registerNib:forSupplementaryViewOfKind:withReuseIdentifier:

Registers a nib file for use in creating supplementary views for the collection view.

- dequeueReusableCellWithReuseIdentifier:forIndexPath:

Returns a reusable cell object located by its identifier

- dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath:

Returns a reusable supplementary view located by its identifier and kind.