Conforms to UICollectionViewDataSource
Declared in JSQMessagesCollectionViewDataSource.h

Overview

An object that adopts the JSQMessagesCollectionViewDataSource protocol is responsible for providing the data and views required by a JSQMessagesCollectionView. The data source object represents your app’s messaging data model and vends information to the collection view as needed.

Tasks

Instance Methods

collectionView:attributedTextForCellBottomLabelAtIndexPath:

- (NSAttributedString *)collectionView:(JSQMessagesCollectionView *)collectionView attributedTextForCellBottomLabelAtIndexPath:(NSIndexPath *)indexPath
Discussion

Asks the data source for the text to display in the cellBottomLabel for the the specified message data item at indexPath in the collectionView.

Parameters

collectionView

The collection view requesting this information.

indexPath

The index path that specifies the location of the item.

Return Value

A configured attributed string or nil if you do not want text displayed for the item at indexPath. Return an attributed string with nil attributes to use the default attributes.

Declared In

JSQMessagesCollectionViewDataSource.h

collectionView:attributedTextForCellTopLabelAtIndexPath:

- (NSAttributedString *)collectionView:(JSQMessagesCollectionView *)collectionView attributedTextForCellTopLabelAtIndexPath:(NSIndexPath *)indexPath
Discussion

Asks the data source for the text to display in the cellTopLabel for the specified message data item at indexPath in the collectionView.

Parameters

collectionView

The collection view requesting this information.

indexPath

The index path that specifies the location of the item.

Return Value

A configured attributed string or nil if you do not want text displayed for the item at indexPath. Return an attributed string with nil attributes to use the default attributes.

Declared In

JSQMessagesCollectionViewDataSource.h

collectionView:attributedTextForMessageBubbleTopLabelAtIndexPath:

- (NSAttributedString *)collectionView:(JSQMessagesCollectionView *)collectionView attributedTextForMessageBubbleTopLabelAtIndexPath:(NSIndexPath *)indexPath
Discussion

Asks the data source for the text to display in the messageBubbleTopLabel for the specified message data item at indexPath in the collectionView.

Parameters

collectionView

The collection view requesting this information.

indexPath

The index path that specifies the location of the item.

Return Value

A configured attributed string or nil if you do not want text displayed for the item at indexPath. Return an attributed string with nil attributes to use the default attributes.

Declared In

JSQMessagesCollectionViewDataSource.h

collectionView:avatarImageDataForItemAtIndexPath:

- (id<JSQMessageAvatarImageDataSource>)collectionView:(JSQMessagesCollectionView *)collectionView avatarImageDataForItemAtIndexPath:(NSIndexPath *)indexPath
Discussion

Asks the data source for the avatar image data that corresponds to the specified message data item at indexPath in the collectionView.

It is recommended that you utilize JSQMessagesAvatarImageFactory to return valid JSQMessagesAvatarImage objects. However, you may provide your own data source object as long as it conforms to the JSQMessageAvatarImageDataSource protocol.

Parameters

collectionView

The collection view requesting this information.

indexPath

The index path that specifies the location of the item.

Return Value

A initialized object that conforms to the JSQMessageAvatarImageDataSource protocol. You may return nil from this method if you do not want the specified item to display an avatar.

Declared In

JSQMessagesCollectionViewDataSource.h

collectionView:didDeleteMessageAtIndexPath:

- (void)collectionView:(JSQMessagesCollectionView *)collectionView didDeleteMessageAtIndexPath:(NSIndexPath *)indexPath
Discussion

Notifies the data source that the item at indexPath has been deleted. Implementations of this method should remove the item from the data source.

Parameters

collectionView

The collection view requesting this information.

indexPath

The index path that specifies the location of the item.

Declared In

JSQMessagesCollectionViewDataSource.h

collectionView:messageBubbleImageDataForItemAtIndexPath:

- (id<JSQMessageBubbleImageDataSource>)collectionView:(JSQMessagesCollectionView *)collectionView messageBubbleImageDataForItemAtIndexPath:(NSIndexPath *)indexPath
Discussion

Asks the data source for the message bubble image data that corresponds to the specified message data item at indexPath in the collectionView.

It is recommended that you utilize JSQMessagesBubbleImageFactory to return valid JSQMessagesBubbleImage objects. However, you may provide your own data source object as long as it conforms to the JSQMessageBubbleImageDataSource protocol.

Warning: Note that providing your own bubble image data source objects may require additional configuration of the collectionView layout object, specifically regarding its messageBubbleTextViewFrameInsets and messageBubbleTextViewTextContainerInsets.

Parameters

collectionView

The collection view requesting this information.

indexPath

The index path that specifies the location of the item.

Return Value

An initialized object that conforms to the JSQMessageBubbleImageDataSource protocol. You may return nil from this method if you do not want the specified item to display a message bubble image.

Declared In

JSQMessagesCollectionViewDataSource.h

collectionView:messageDataForItemAtIndexPath:

- (id<JSQMessageData>)collectionView:(JSQMessagesCollectionView *)collectionView messageDataForItemAtIndexPath:(NSIndexPath *)indexPath
Discussion

Asks the data source for the message data that corresponds to the specified item at indexPath in the collectionView.

Parameters

collectionView

The collection view requesting this information.

indexPath

The index path that specifies the location of the item.

Return Value

An initialized object that conforms to the JSQMessageData protocol. You must not return nil from this method.

Declared In

JSQMessagesCollectionViewDataSource.h

senderDisplayName

- (NSString *)senderDisplayName
Discussion

Asks the data source for the current sender’s display name, that is, the current user who is sending messages.

Warning: You must not return nil from this method. This value does not need to be unique.

Return Value

An initialized string describing the current sender to display in a JSQMessagesCollectionViewCell.

Declared In

JSQMessagesCollectionViewDataSource.h

senderId

- (NSString *)senderId
Discussion

Asks the data source for the current sender’s unique identifier, that is, the current user who is sending messages.

Warning: You must not return nil from this method. This value must be unique.

Return Value

An initialized string identifier that uniquely identifies the current sender.

Declared In

JSQMessagesCollectionViewDataSource.h