Forráskód Böngészése

Merge pull request #1338 from wolfcon/enhancement/support-swift-optionals

新增 Swift Optionals 支持
M了个J 6 éve
szülő
commit
4287a4f6b4

+ 4 - 0
MJRefresh/Base/MJRefreshAutoFooter.h

@@ -8,6 +8,8 @@
 
 #import "MJRefreshFooter.h"
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface MJRefreshAutoFooter : MJRefreshFooter
 /** 是否自动刷新(默认为YES) */
 @property (assign, nonatomic, getter=isAutomaticallyRefresh) BOOL automaticallyRefresh;
@@ -21,3 +23,5 @@
 /** 是否每一次拖拽只发一次请求 */
 @property (assign, nonatomic, getter=isOnlyRefreshPerDrag) BOOL onlyRefreshPerDrag;
 @end
+
+NS_ASSUME_NONNULL_END

+ 4 - 0
MJRefresh/Base/MJRefreshBackFooter.h

@@ -8,6 +8,10 @@
 
 #import "MJRefreshFooter.h"
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface MJRefreshBackFooter : MJRefreshFooter
 
 @end
+
+NS_ASSUME_NONNULL_END

+ 12 - 7
MJRefresh/Base/MJRefreshComponent.h

@@ -14,6 +14,8 @@
 #import "UIScrollView+MJRefresh.h"
 #import "NSBundle+MJRefresh.h"
 
+NS_ASSUME_NONNULL_BEGIN
+
 /** 刷新控件的状态 */
 typedef NS_ENUM(NSInteger, MJRefreshState) {
     /** 普通闲置状态 */
@@ -45,7 +47,7 @@ typedef void (^MJRefreshComponentEndRefreshingCompletionBlock)(void);
 }
 #pragma mark - 刷新回调
 /** 正在刷新的回调 */
-@property (copy, nonatomic) MJRefreshComponentRefreshingBlock refreshingBlock;
+@property (copy, nonatomic, nullable) MJRefreshComponentRefreshingBlock refreshingBlock;
 /** 设置回调对象和回调方法 */
 - (void)setRefreshingTarget:(id)target refreshingAction:(SEL)action;
 
@@ -61,11 +63,11 @@ typedef void (^MJRefreshComponentEndRefreshingCompletionBlock)(void);
 - (void)beginRefreshing;
 - (void)beginRefreshingWithCompletionBlock:(void (^)(void))completionBlock;
 /** 开始刷新后的回调(进入刷新状态后的回调) */
-@property (copy, nonatomic) MJRefreshComponentBeginRefreshingCompletionBlock beginRefreshingCompletionBlock;
+@property (copy, nonatomic, nullable) MJRefreshComponentBeginRefreshingCompletionBlock beginRefreshingCompletionBlock;
 /** 带动画的结束刷新的回调 */
-@property (copy, nonatomic) MJRefreshComponentEndRefreshingCompletionBlock endRefreshingAnimateCompletionBlock;
+@property (copy, nonatomic, nullable) MJRefreshComponentEndRefreshingCompletionBlock endRefreshingAnimateCompletionBlock;
 /** 结束刷新的回调 */
-@property (copy, nonatomic) MJRefreshComponentEndRefreshingCompletionBlock endRefreshingCompletionBlock;
+@property (copy, nonatomic, nullable) MJRefreshComponentEndRefreshingCompletionBlock endRefreshingCompletionBlock;
 /** 结束刷新状态 */
 - (void)endRefreshing;
 - (void)endRefreshingWithCompletionBlock:(void (^)(void))completionBlock;
@@ -87,11 +89,11 @@ typedef void (^MJRefreshComponentEndRefreshingCompletionBlock)(void);
 /** 摆放子控件frame */
 - (void)placeSubviews NS_REQUIRES_SUPER;
 /** 当scrollView的contentOffset发生改变的时候调用 */
-- (void)scrollViewContentOffsetDidChange:(NSDictionary *)change NS_REQUIRES_SUPER;
+- (void)scrollViewContentOffsetDidChange:(nullable NSDictionary *)change NS_REQUIRES_SUPER;
 /** 当scrollView的contentSize发生改变的时候调用 */
-- (void)scrollViewContentSizeDidChange:(NSDictionary *)change NS_REQUIRES_SUPER;
+- (void)scrollViewContentSizeDidChange:(nullable NSDictionary *)change NS_REQUIRES_SUPER;
 /** 当scrollView的拖拽状态发生改变的时候调用 */
-- (void)scrollViewPanStateDidChange:(NSDictionary *)change NS_REQUIRES_SUPER;
+- (void)scrollViewPanStateDidChange:(nullable NSDictionary *)change NS_REQUIRES_SUPER;
 
 
 #pragma mark - 其他
@@ -107,3 +109,6 @@ typedef void (^MJRefreshComponentEndRefreshingCompletionBlock)(void);
 + (instancetype)mj_label;
 - (CGFloat)mj_textWidth;
 @end
+
+
+NS_ASSUME_NONNULL_END

+ 4 - 0
MJRefresh/Base/MJRefreshFooter.h

@@ -9,6 +9,8 @@
 
 #import "MJRefreshComponent.h"
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface MJRefreshFooter : MJRefreshComponent
 /** 创建footer */
 + (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock;
@@ -28,3 +30,5 @@
 /** 自动根据有无数据来显示和隐藏(有数据就显示,没有数据隐藏。默认是NO) */
 @property (assign, nonatomic, getter=isAutomaticallyHidden) BOOL automaticallyHidden MJRefreshDeprecated("已废弃此属性,开发者请自行控制footer的显示和隐藏");
 @end
+
+NS_ASSUME_NONNULL_END

+ 5 - 1
MJRefresh/Base/MJRefreshHeader.h

@@ -9,6 +9,8 @@
 
 #import "MJRefreshComponent.h"
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface MJRefreshHeader : MJRefreshComponent
 /** 创建header */
 + (instancetype)headerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock;
@@ -18,8 +20,10 @@
 /** 这个key用来存储上一次下拉刷新成功的时间 */
 @property (copy, nonatomic) NSString *lastUpdatedTimeKey;
 /** 上一次下拉刷新成功的时间 */
-@property (strong, nonatomic, readonly) NSDate *lastUpdatedTime;
+@property (strong, nonatomic, readonly, nullable) NSDate *lastUpdatedTime;
 
 /** 忽略多少scrollView的contentInset的top */
 @property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetTop;
 @end
+
+NS_ASSUME_NONNULL_END

+ 4 - 0
MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h

@@ -8,6 +8,8 @@
 
 #import "MJRefreshAutoStateFooter.h"
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface MJRefreshAutoGifFooter : MJRefreshAutoStateFooter
 @property (weak, nonatomic, readonly) UIImageView *gifView;
 
@@ -15,3 +17,5 @@
 - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state;
 - (void)setImages:(NSArray *)images forState:(MJRefreshState)state;
 @end
+
+NS_ASSUME_NONNULL_END

+ 5 - 0
MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h

@@ -8,7 +8,12 @@
 
 #import "MJRefreshAutoStateFooter.h"
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface MJRefreshAutoNormalFooter : MJRefreshAutoStateFooter
 /** 菊花的样式 */
 @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle;
 @end
+
+
+NS_ASSUME_NONNULL_END

+ 4 - 0
MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h

@@ -8,6 +8,8 @@
 
 #import "MJRefreshAutoFooter.h"
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface MJRefreshAutoStateFooter : MJRefreshAutoFooter
 /** 文字距离圈圈、箭头的距离 */
 @property (assign, nonatomic) CGFloat labelLeftInset;
@@ -20,3 +22,5 @@
 /** 隐藏刷新状态的文字 */
 @property (assign, nonatomic, getter=isRefreshingTitleHidden) BOOL refreshingTitleHidden;
 @end
+
+NS_ASSUME_NONNULL_END

+ 4 - 0
MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h

@@ -8,6 +8,8 @@
 
 #import "MJRefreshBackStateFooter.h"
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface MJRefreshBackGifFooter : MJRefreshBackStateFooter
 @property (weak, nonatomic, readonly) UIImageView *gifView;
 
@@ -15,3 +17,5 @@
 - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state;
 - (void)setImages:(NSArray *)images forState:(MJRefreshState)state;
 @end
+
+NS_ASSUME_NONNULL_END

+ 4 - 0
MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h

@@ -8,8 +8,12 @@
 
 #import "MJRefreshBackStateFooter.h"
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface MJRefreshBackNormalFooter : MJRefreshBackStateFooter
 @property (weak, nonatomic, readonly) UIImageView *arrowView;
 /** 菊花的样式 */
 @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle;
 @end
+
+NS_ASSUME_NONNULL_END

+ 4 - 0
MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h

@@ -8,6 +8,8 @@
 
 #import "MJRefreshBackFooter.h"
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface MJRefreshBackStateFooter : MJRefreshBackFooter
 /** 文字距离圈圈、箭头的距离 */
 @property (assign, nonatomic) CGFloat labelLeftInset;
@@ -19,3 +21,5 @@
 /** 获取state状态下的title */
 - (NSString *)titleForState:(MJRefreshState)state;
 @end
+
+NS_ASSUME_NONNULL_END

+ 4 - 0
MJRefresh/Custom/Header/MJRefreshGifHeader.h

@@ -8,6 +8,8 @@
 
 #import "MJRefreshStateHeader.h"
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface MJRefreshGifHeader : MJRefreshStateHeader
 @property (weak, nonatomic, readonly) UIImageView *gifView;
 
@@ -15,3 +17,5 @@
 - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state;
 - (void)setImages:(NSArray *)images forState:(MJRefreshState)state;
 @end
+
+NS_ASSUME_NONNULL_END

+ 4 - 0
MJRefresh/Custom/Header/MJRefreshNormalHeader.h

@@ -8,6 +8,8 @@
 
 #import "MJRefreshStateHeader.h"
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface MJRefreshNormalHeader : MJRefreshStateHeader
 @property (weak, nonatomic, readonly) UIImageView *arrowView;
 @property (weak, nonatomic, readonly) UIActivityIndicatorView *loadingView;
@@ -16,3 +18,5 @@
 /** 菊花的样式 */
 @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle MJRefreshDeprecated("请使用 loadingView 进行设置");
 @end
+
+NS_ASSUME_NONNULL_END

+ 5 - 1
MJRefresh/Custom/Header/MJRefreshStateHeader.h

@@ -8,10 +8,12 @@
 
 #import "MJRefreshHeader.h"
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface MJRefreshStateHeader : MJRefreshHeader
 #pragma mark - 刷新时间相关
 /** 利用这个block来决定显示的更新时间文字 */
-@property (copy, nonatomic) NSString *(^lastUpdatedTimeText)(NSDate *lastUpdatedTime);
+@property (copy, nonatomic, nullable) NSString *(^lastUpdatedTimeText)(NSDate *lastUpdatedTime);
 /** 显示上一次刷新时间的label */
 @property (weak, nonatomic, readonly) UILabel *lastUpdatedTimeLabel;
 
@@ -23,3 +25,5 @@
 /** 设置state状态下的文字 */
 - (void)setTitle:(NSString *)title forState:(MJRefreshState)state;
 @end
+
+NS_ASSUME_NONNULL_END

+ 0 - 1
MJRefresh/MJRefreshConst.h

@@ -73,4 +73,3 @@ dispatch_async(dispatch_get_main_queue(), ^{ \
 typeof(weakSelf) self = weakSelf; \
 {x} \
 });
-

+ 5 - 1
MJRefresh/NSBundle+MJRefresh.h

@@ -8,9 +8,13 @@
 
 #import <UIKit/UIKit.h>
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface NSBundle (MJRefresh)
 + (instancetype)mj_refreshBundle;
 + (UIImage *)mj_arrowImage;
-+ (NSString *)mj_localizedStringForKey:(NSString *)key value:(NSString *)value;
++ (NSString *)mj_localizedStringForKey:(NSString *)key value:(nullable NSString *)value;
 + (NSString *)mj_localizedStringForKey:(NSString *)key;
 @end
+
+NS_ASSUME_NONNULL_END

+ 4 - 0
MJRefresh/UIScrollView+MJExtension.h

@@ -9,6 +9,8 @@
 
 #import <UIKit/UIKit.h>
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface UIScrollView (MJExtension)
 @property (readonly, nonatomic) UIEdgeInsets mj_inset;
 
@@ -23,3 +25,5 @@
 @property (assign, nonatomic) CGFloat mj_contentW;
 @property (assign, nonatomic) CGFloat mj_contentH;
 @end
+
+NS_ASSUME_NONNULL_END

+ 8 - 4
MJRefresh/UIScrollView+MJRefresh.h

@@ -12,15 +12,19 @@
 
 @class MJRefreshHeader, MJRefreshFooter;
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface UIScrollView (MJRefresh)
 /** 下拉刷新控件 */
-@property (strong, nonatomic) MJRefreshHeader *mj_header;
-@property (strong, nonatomic) MJRefreshHeader *header MJRefreshDeprecated("使用mj_header");
+@property (strong, nonatomic, nullable) MJRefreshHeader *mj_header;
+@property (strong, nonatomic, nullable) MJRefreshHeader *header MJRefreshDeprecated("使用mj_header");
 /** 上拉刷新控件 */
-@property (strong, nonatomic) MJRefreshFooter *mj_footer;
-@property (strong, nonatomic) MJRefreshFooter *footer MJRefreshDeprecated("使用mj_footer");
+@property (strong, nonatomic, nullable) MJRefreshFooter *mj_footer;
+@property (strong, nonatomic, nullable) MJRefreshFooter *footer MJRefreshDeprecated("使用mj_footer");
 
 #pragma mark - other
 - (NSInteger)mj_totalDataCount;
 
 @end
+
+NS_ASSUME_NONNULL_END

+ 4 - 0
MJRefresh/UIView+MJExtension.h

@@ -9,6 +9,8 @@
 
 #import <UIKit/UIKit.h>
 
+NS_ASSUME_NONNULL_BEGIN
+
 @interface UIView (MJExtension)
 @property (assign, nonatomic) CGFloat mj_x;
 @property (assign, nonatomic) CGFloat mj_y;
@@ -17,3 +19,5 @@
 @property (assign, nonatomic) CGSize mj_size;
 @property (assign, nonatomic) CGPoint mj_origin;
 @end
+
+NS_ASSUME_NONNULL_END