Skip to content
This repository has been archived by the owner on Aug 24, 2019. It is now read-only.

Add nullability annotations #67

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions SSPullToRefresh/SSPullToRefreshDefaultContentView.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@

#import "SSPullToRefreshView.h"

NS_ASSUME_NONNULL_BEGIN

@interface SSPullToRefreshDefaultContentView : UIView <SSPullToRefreshContentView>

@property (nonatomic, readonly) UILabel *statusLabel;
@property (nonatomic, readonly) UILabel *lastUpdatedAtLabel;
@property (nonatomic, readonly) UIActivityIndicatorView *activityIndicatorView;

@end

NS_ASSUME_NONNULL_END
4 changes: 4 additions & 0 deletions SSPullToRefresh/SSPullToRefreshSimpleContentView.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@

#import "SSPullToRefreshView.h"

NS_ASSUME_NONNULL_BEGIN

@interface SSPullToRefreshSimpleContentView : UIView <SSPullToRefreshContentView>

@property (nonatomic, readonly) UILabel *statusLabel;
@property (nonatomic, readonly) UIActivityIndicatorView *activityIndicatorView;

@end

NS_ASSUME_NONNULL_END
12 changes: 8 additions & 4 deletions SSPullToRefresh/SSPullToRefreshView.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ typedef NS_ENUM(NSUInteger, SSPullToRefreshViewStyle) {
@protocol SSPullToRefreshViewDelegate;
@protocol SSPullToRefreshContentView;

NS_ASSUME_NONNULL_BEGIN

@interface SSPullToRefreshView : UIView

/**
Expand Down Expand Up @@ -105,15 +107,15 @@ typedef NS_ENUM(NSUInteger, SSPullToRefreshViewStyle) {

@see initWithScrollView:delegate:
*/
@property (nonatomic, assign, readonly) UIScrollView *scrollView;
@property (nonatomic, weak, readonly, nullable) UIScrollView *scrollView;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, the change from assign to weak caused a crash for me:

Fatal Exception: NSInternalInconsistencyException
An instance 0x1062ae600 of class UICollectionView was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x17082c9a0> ( <NSKeyValueObservance 0x171243ea0: Observer: 0x105d80720, Key path: contentOffset, Options: <New: YES, Old: NO, Prior: NO> Context: 0x105d80720, Property: 0x174c42d30> )

It occurs on iOS 9 & 10 (not 11), when popping from one VC to another, both with a collection view with a pull to refresh.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert back to unsafe_unretained (same as assign). this is because of kvo. ref: https://stackoverflow.com/questions/10793206/how-do-you-remove-kvo-from-a-weak-property posted by sam himself

lemme know if this works


/**
The delegate is sent messages when the pull to refresh view starts loading. This is automatically set with `initWithScrollView:delegate:`.

@see initWithScrollView:delegate:
@see SSPullToRefreshViewDelegate
*/
@property (nonatomic, weak) id<SSPullToRefreshViewDelegate> delegate;
@property (nonatomic, weak, nullable) id<SSPullToRefreshViewDelegate> delegate;

/**
The state of the pull to refresh view.
Expand Down Expand Up @@ -156,13 +158,13 @@ typedef NS_ENUM(NSUInteger, SSPullToRefreshViewStyle) {
animate down the pull to refresh view to show that it's loading.
*/
- (void)startLoadingAndExpand:(BOOL)shouldExpand animated:(BOOL)animated;
- (void)startLoadingAndExpand:(BOOL)shouldExpand animated:(BOOL)animated completion:(void(^)(void))block;
- (void)startLoadingAndExpand:(BOOL)shouldExpand animated:(BOOL)animated completion:(nullable void(^)(void))block;

/**
Call this when you finish loading.
*/
- (void)finishLoading;
- (void)finishLoadingAnimated:(BOOL)animated completion:(void(^)(void))block;
- (void)finishLoadingAnimated:(BOOL)animated completion:(nullable void(^)(void))block;

/**
Manually update the last updated at time. This will automatically get called when the pull to refresh view finishes laoding.
Expand Down Expand Up @@ -240,3 +242,5 @@ typedef NS_ENUM(NSUInteger, SSPullToRefreshViewStyle) {
- (void)setLastUpdatedAt:(NSDate *)date withPullToRefreshView:(SSPullToRefreshView *)view;

@end

NS_ASSUME_NONNULL_END