Skip to content

Commit

Permalink
Added nullability.
Browse files Browse the repository at this point in the history
  • Loading branch information
matej committed Jan 31, 2016
1 parent de4938c commit 011c76e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
21 changes: 13 additions & 8 deletions MBProgressHUD.h
Expand Up @@ -70,6 +70,9 @@ typedef NS_ENUM(NSInteger, MBProgressHUDBackgroundStyle) {
};


NS_ASSUME_NONNULL_BEGIN


/**
* Displays a simple HUD window containing a progress indicator and two optional labels for short messages.
*
Expand Down Expand Up @@ -120,7 +123,7 @@ typedef NS_ENUM(NSInteger, MBProgressHUDBackgroundStyle) {
* @param view The view that is going to be searched.
* @return A reference to the last HUD subview discovered.
*/
+ (MBProgressHUD *)HUDForView:(UIView *)view;
+ (nullable MBProgressHUD *)HUDForView:(UIView *)view;

/**
* A convenience constructor that initializes the HUD with the view's bounds. Calls the designated constructor with
Expand Down Expand Up @@ -207,7 +210,7 @@ typedef NS_ENUM(NSInteger, MBProgressHUDBackgroundStyle) {
* for custom views on iOS 7+. Set to nil to manage color individually.
* Defaults to semi-translucent black on iOS 7 and later and white on earlier iOS versions.
*/
@property (strong, nonatomic) UIColor *contentColor UI_APPEARANCE_SELECTOR;
@property (strong, nonatomic, nullable) UIColor *contentColor UI_APPEARANCE_SELECTOR;

/**
* The animation type that should be used when the HUD is shown and hidden.
Expand Down Expand Up @@ -267,7 +270,7 @@ typedef NS_ENUM(NSInteger, MBProgressHUDBackgroundStyle) {
* The UIView (e.g., a UIImageView) to be shown when the HUD is in MBProgressHUDModeCustomView.
* The view should implement intrinsicContentSize for proper sizing. For best results use approximately 37 by 37 pixel.
*/
@property (strong, nonatomic) UIView *customView;
@property (strong, nonatomic, nullable) UIView *customView;

/**
* A label that holds an optional short message to be displayed below the activity indicator. The HUD is automatically resized to fit
Expand Down Expand Up @@ -324,7 +327,7 @@ typedef NS_ENUM(NSInteger, MBProgressHUDBackgroundStyle) {
@property (nonatomic, strong) UIColor *backgroundTintColor;

/*
* Display mode - NO = round or YES = annular. Defaults to round.
* Display mode - NO = round or YES = annular. De+faults to round.
*/
@property (nonatomic, assign, getter = isAnnular) BOOL annular;

Expand Down Expand Up @@ -394,12 +397,12 @@ typedef void (^MBProgressHUDCompletionBlock)();

- (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated __attribute__((deprecated("Use GCD directly.")));
- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block __attribute__((deprecated("Use GCD directly.")));
- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block completionBlock:(MBProgressHUDCompletionBlock)completion __attribute__((deprecated("Use GCD directly.")));
- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block completionBlock:(nullable MBProgressHUDCompletionBlock)completion __attribute__((deprecated("Use GCD directly.")));
- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue __attribute__((deprecated("Use GCD directly.")));
- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue
completionBlock:(MBProgressHUDCompletionBlock)completion __attribute__((deprecated("Use GCD directly.")));
@property (copy) MBProgressHUDCompletionBlock completionBlock __attribute__((deprecated("Use GCD directly.")));
@property (assign) BOOL taskInProgress __attribute__((deprecated("No longer needed for .")));
completionBlock:(nullable MBProgressHUDCompletionBlock)completion __attribute__((deprecated("Use GCD directly.")));
@property (copy, nullable) MBProgressHUDCompletionBlock completionBlock __attribute__((deprecated("Use GCD directly.")));
@property (assign) BOOL taskInProgress __attribute__((deprecated("No longer needed.")));

@property (nonatomic, copy) NSString *labelText __attribute__((deprecated("Use label.text instead.")));
@property (nonatomic, strong) UIFont *labelFont __attribute__((deprecated("Use label.font instead.")));
Expand All @@ -417,3 +420,5 @@ typedef void (^MBProgressHUDCompletionBlock)();
@property (atomic, assign, readonly) CGSize size __attribute__((deprecated("Get the bezelView.frame.size instead.")));

@end

NS_ASSUME_NONNULL_END
10 changes: 7 additions & 3 deletions MBProgressHUD.m
Expand Up @@ -42,7 +42,7 @@ @interface MBProgressHUD () {
@property (nonatomic, strong) UIView *bottomSpacer;

// Deprecated
@property (copy) MBProgressHUDCompletionBlock completionBlock;
@property (copy, nullable) MBProgressHUDCompletionBlock completionBlock;
@property (assign) BOOL taskInProgress;

@end
Expand Down Expand Up @@ -742,13 +742,15 @@ - (void)setProgress:(float)progress {
}

- (void)setProgressTintColor:(UIColor *)progressTintColor {
NSAssert(progressTintColor, @"The color should not be nil.");
if (progressTintColor != _progressTintColor && ![progressTintColor isEqual:_progressTintColor]) {
_progressTintColor = progressTintColor;
[self setNeedsDisplay];
}
}

- (void)setBackgroundTintColor:(UIColor *)backgroundTintColor {
NSAssert(backgroundTintColor, @"The color should not be nil.");
if (backgroundTintColor != _backgroundTintColor && ![backgroundTintColor isEqual:_backgroundTintColor]) {
_backgroundTintColor = backgroundTintColor;
[self setNeedsDisplay];
Expand Down Expand Up @@ -862,13 +864,15 @@ - (void)setProgress:(float)progress {
}

- (void)setProgressColor:(UIColor *)progressColor {
NSAssert(progressColor, @"The color should not be nil.");
if (progressColor != _progressColor && ![progressColor isEqual:_progressColor]) {
_progressColor = progressColor;
[self setNeedsDisplay];
}
}

- (void)setProgressRemainingColor:(UIColor *)progressRemainingColor {
NSAssert(progressRemainingColor, @"The color should not be nil.");
if (progressRemainingColor != _progressRemainingColor && ![progressRemainingColor isEqual:_progressRemainingColor]) {
_progressRemainingColor = progressRemainingColor;
[self setNeedsDisplay];
Expand Down Expand Up @@ -1019,6 +1023,7 @@ - (void)setStyle:(MBProgressHUDBackgroundStyle)style {
}

- (void)setColor:(UIColor *)color {
NSAssert(color, @"The color should not be nil.");
if (color != _color && ![color isEqual:_color]) {
_color = color;
[self updateViewsForColor:color];
Expand Down Expand Up @@ -1146,8 +1151,7 @@ - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block
[self showAnimated:animated whileExecutingBlock:block onQueue:queue completionBlock:NULL];
}

- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue
completionBlock:(MBProgressHUDCompletionBlock)completion {
- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue completionBlock:(nullable MBProgressHUDCompletionBlock)completion {
self.taskInProgress = YES;
self.completionBlock = completion;
dispatch_async(queue, ^(void) {
Expand Down

0 comments on commit 011c76e

Please sign in to comment.