Skip to content

Commit 5627228

Browse files
committed
expose cache countLimit. set default to 200. ref: jessesquires#492
1 parent 4281751 commit 5627228

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

JSQMessagesViewController/Layout/JSQMessagesCollectionViewFlowLayout.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ FOUNDATION_EXPORT const CGFloat kJSQMessagesCollectionViewAvatarSizeDefault;
167167
*/
168168
@property (assign, nonatomic) CGSize outgoingAvatarViewSize;
169169

170+
/**
171+
* The maximum number of items that the layout should keep in its cache of layout information.
172+
*
173+
* @discussion The default value is `200`. A limit of `0` means no limit. This is not a strict limit.
174+
*/
175+
@property (assign, nonatomic) NSUInteger cacheLimit;
176+
170177
/**
171178
* Computes and returns the size of the `messageBubbleImageView` property of a `JSQMessagesCollectionViewCell`
172179
* at the specified indexPath. The returned size contains the required dimensions to display the entire message contents.

JSQMessagesViewController/Layout/JSQMessagesCollectionViewFlowLayout.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ - (void)jsq_configureFlowLayout
8383

8484
_messageBubbleCache = [NSCache new];
8585
_messageBubbleCache.name = @"JSQMessagesCollectionViewFlowLayout.messageBubbleCache";
86-
_messageBubbleCache.countLimit = 100;
86+
_messageBubbleCache.countLimit = 200;
8787

8888
_messageBubbleFont = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
8989

@@ -221,6 +221,11 @@ - (void)setOutgoingAvatarViewSize:(CGSize)outgoingAvatarViewSize
221221
[self invalidateLayoutWithContext:[JSQMessagesCollectionViewFlowLayoutInvalidationContext context]];
222222
}
223223

224+
- (void)setCacheLimit:(NSUInteger)cacheLimit
225+
{
226+
self.messageBubbleCache.countLimit = cacheLimit;
227+
}
228+
224229
#pragma mark - Getters
225230

226231
- (CGFloat)itemWidth
@@ -244,6 +249,11 @@ - (NSMutableSet *)visibleIndexPaths
244249
return _visibleIndexPaths;
245250
}
246251

252+
- (NSUInteger)cacheLimit
253+
{
254+
return self.messageBubbleCache.countLimit;
255+
}
256+
247257
#pragma mark - Notifications
248258

249259
- (void)jsq_didReceiveApplicationMemoryWarningNotification:(NSNotification *)notification

0 commit comments

Comments
 (0)