Skip to content

Commit

Permalink
Merge pull request Tencent#389 from wxlpp/Swift
Browse files Browse the repository at this point in the history
Nullability and Objective-C
  • Loading branch information
MoLice authored Aug 24, 2018
2 parents 93c3cfd + d1deadd commit 7b05d2d
Show file tree
Hide file tree
Showing 22 changed files with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ extern const UIEdgeInsets QMUIAlbumTableViewCellDefaultAlbumNameInsets;

@interface QMUIAlbumViewController (UIAppearance)

+ (instancetype)appearance;
+ (nonnull instancetype)appearance;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ + (void)initialize {
}

static QMUIAlbumViewController *albumViewControllerAppearance;
+ (instancetype)appearance {
+ (nonnull instancetype)appearance {
static dispatch_once_t onceToken2;
dispatch_once(&onceToken2, ^{
if (!albumViewControllerAppearance) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@

@interface QMUIImagePickerPreviewViewController (UIAppearance)

+ (instancetype)appearance;
+ (nonnull instancetype)appearance;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ + (void)initialize {
}

static QMUIImagePickerPreviewViewController *imagePickerPreviewViewControllerAppearance;
+ (instancetype)appearance {
+ (nonnull instancetype)appearance {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (!imagePickerPreviewViewControllerAppearance) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,6 @@

@interface QMUIImagePickerViewController (UIAppearance)

+ (instancetype)appearance;
+ (nonnull instancetype)appearance;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ + (void)initialize {
}

static QMUIImagePickerViewController *imagePickerViewControllerAppearance;
+ (instancetype)appearance {
+ (nonnull instancetype)appearance {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (!imagePickerViewControllerAppearance) {
Expand Down
10 changes: 5 additions & 5 deletions QMUIKit/QMUIComponents/QMUIAlertController.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ typedef NS_ENUM(NSInteger, QMUIAlertControllerStyle) {
*
* @return QMUIAlertController按钮的实例
*/
+ (instancetype)actionWithTitle:(nullable NSString *)title style:(QMUIAlertActionStyle)style handler:(nullable void (^)(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action))handler;
+ (nonnull instancetype)actionWithTitle:(nullable NSString *)title style:(QMUIAlertActionStyle)style handler:(nullable void (^)(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action))handler;

/// `QMUIAlertAction`对应的 button 对象
@property(nonatomic, strong, readonly) QMUIButton *button;
Expand Down Expand Up @@ -196,16 +196,16 @@ typedef NS_ENUM(NSInteger, QMUIAlertControllerStyle) {


/// 默认初始化方法
- (instancetype)initWithTitle:(NSString *)title message:(NSString *)message preferredStyle:(QMUIAlertControllerStyle)preferredStyle;
- (nonnull instancetype)initWithTitle:(nullable NSString *)title message:(nullable NSString *)message preferredStyle:(QMUIAlertControllerStyle)preferredStyle;

/// 通过类方法初始化实例
+ (instancetype)alertControllerWithTitle:(NSString *)title message:(NSString *)message preferredStyle:(QMUIAlertControllerStyle)preferredStyle;
+ (nonnull instancetype)alertControllerWithTitle:(nullable NSString *)title message:(nullable NSString *)message preferredStyle:(QMUIAlertControllerStyle)preferredStyle;

/// @see `QMUIAlertControllerDelegate`
@property(nonatomic,weak) id<QMUIAlertControllerDelegate>delegate;

/// 增加一个按钮
- (void)addAction:(QMUIAlertAction *)action;
- (void)addAction:(nonnull QMUIAlertAction *)action;

// 增加一个“取消”按钮,点击后 alertController 会被 hide
- (void)addCancelAction;
Expand Down Expand Up @@ -271,7 +271,7 @@ typedef NS_ENUM(NSInteger, QMUIAlertControllerStyle) {

@interface QMUIAlertController (UIAppearance)

+ (instancetype)appearance;
+ (nonnull instancetype)appearance;

@end

Expand Down
12 changes: 6 additions & 6 deletions QMUIKit/QMUIComponents/QMUIAlertController.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ @interface QMUIAlertAction ()

@implementation QMUIAlertAction

+ (instancetype)actionWithTitle:(NSString *)title style:(QMUIAlertActionStyle)style handler:(void (^)(__kindof QMUIAlertController *, QMUIAlertAction *))handler {
+ (nonnull instancetype)actionWithTitle:(nullable NSString *)title style:(QMUIAlertActionStyle)style handler:(void (^)(__kindof QMUIAlertController *, QMUIAlertAction *))handler {
QMUIAlertAction *alertAction = [[QMUIAlertAction alloc] init];
alertAction.title = title;
alertAction.style = style;
alertAction.handler = handler;
return alertAction;
}

- (instancetype)init {
- (nonnull instancetype)init {
self = [super init];
if (self) {
_button = [[QMUIButton alloc] init];
Expand Down Expand Up @@ -111,7 +111,7 @@ + (void)initialize {
}

static QMUIAlertController *alertControllerAppearance;
+ (instancetype)appearance {
+ (nonnull instancetype)appearance {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[self resetAppearance];
Expand Down Expand Up @@ -501,15 +501,15 @@ - (void)setCancelButtonVisualEffectView:(UIView *)cancelButtonVisualEffectView {
}
}

+ (instancetype)alertControllerWithTitle:(NSString *)title message:(NSString *)message preferredStyle:(QMUIAlertControllerStyle)preferredStyle {
+ (nonnull instancetype)alertControllerWithTitle:(nullable NSString *)title message:(nullable NSString *)message preferredStyle:(QMUIAlertControllerStyle)preferredStyle {
QMUIAlertController *alertController = [[self alloc] initWithTitle:title message:message preferredStyle:preferredStyle];
if (alertController) {
return alertController;
}
return nil;
}

- (instancetype)initWithTitle:(NSString *)title message:(NSString *)message preferredStyle:(QMUIAlertControllerStyle)preferredStyle {
- (nonnull instancetype)initWithTitle:(nullable NSString *)title message:(nullable NSString *)message preferredStyle:(QMUIAlertControllerStyle)preferredStyle {
self = [self init];
if (self) {

Expand Down Expand Up @@ -969,7 +969,7 @@ - (void)hideWithAnimated:(BOOL)animated completion:(void (^)(void))completion {
alertControllerCount--;
}

- (void)addAction:(QMUIAlertAction *)action {
- (void)addAction:(nonnull QMUIAlertAction *)action {
if (action.style == QMUIAlertActionStyleCancel && self.cancelAction) {
[NSException raise:@"QMUIAlertController使用错误" format:@"同一个alertController不可以同时添加两个cancel按钮"];
}
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUIComponents/QMUIDialogViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@

@interface QMUIDialogViewController (UIAppearance)

+ (instancetype)appearance;
+ (nonnull instancetype)appearance;
@end

/// 表示没有选中的item
Expand Down
6 changes: 3 additions & 3 deletions QMUIKit/QMUIComponents/QMUIDialogViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ + (void)initialize {
}

static QMUIDialogViewController *dialogViewControllerAppearance;
+ (instancetype)appearance {
+ (nonnull instancetype)appearance {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (!dialogViewControllerAppearance) {
Expand Down Expand Up @@ -443,7 +443,7 @@ + (void)initialize {
}

static QMUIDialogSelectionViewController *dialogSelectionViewControllerAppearance;
+ (instancetype)appearance {
+ (nonnull instancetype)appearance {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (!dialogSelectionViewControllerAppearance) {
Expand Down Expand Up @@ -651,7 +651,7 @@ + (void)initialize {
}

static QMUIDialogTextFieldViewController *dialogTextFieldViewControllerAppearance;
+ (instancetype)appearance {
+ (nonnull instancetype)appearance {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (!dialogTextFieldViewControllerAppearance) {
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUIComponents/QMUIImagePreviewViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@

@interface QMUIImagePreviewViewController (UIAppearance)

+ (instancetype)appearance;
+ (nonnull instancetype)appearance;
@end
2 changes: 1 addition & 1 deletion QMUIKit/QMUIComponents/QMUIImagePreviewViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ + (void)initialize {
}

static QMUIImagePreviewViewController *imagePreviewViewControllerAppearance;
+ (instancetype)appearance {
+ (nonnull instancetype)appearance {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (!imagePreviewViewControllerAppearance) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ typedef NS_ENUM(NSUInteger, QMUIModalPresentationAnimationStyle) {

@interface QMUIModalPresentationViewController (UIAppearance)

+ (instancetype)appearance;
+ (nonnull instancetype)appearance;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ @interface UIViewController ()
@implementation QMUIModalPresentationViewController (UIAppearance)

static QMUIModalPresentationViewController *appearance;
+ (instancetype)appearance {
+ (nonnull instancetype)appearance {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[self initDefaultAppearance];
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUIComponents/QMUIMoreOperationController.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@

@interface QMUIMoreOperationController (UIAppearance)

+ (instancetype)appearance;
+ (nonnull instancetype)appearance;

@end

Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUIComponents/QMUIMoreOperationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ + (void)initialize {
}

static QMUIMoreOperationController *moreOperationViewControllerAppearance;
+ (instancetype)appearance {
+ (nonnull instancetype)appearance {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[self resetAppearance];
Expand Down
4 changes: 2 additions & 2 deletions QMUIKit/QMUIComponents/ToastView/QMUIToastView.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ typedef NS_ENUM(NSInteger, QMUIToastViewPosition) {
*
* @param view ToastView的superView。
*/
- (instancetype)initWithView:(UIView *)view NS_DESIGNATED_INITIALIZER;
- (nonnull instancetype)initWithView:(nonnull UIView *)view NS_DESIGNATED_INITIALIZER;

/**
* parentView是ToastView初始化的时候传进去的那个view。
Expand Down Expand Up @@ -151,7 +151,7 @@ typedef NS_ENUM(NSInteger, QMUIToastViewPosition) {
* @param view ToastView的superView。
* @return 返回一个QMUIToastView的实例。
*/
+ (instancetype)toastInView:(UIView *)view;
+ (nullable instancetype)toastInView:(UIView *)view;

/**
* 工具方法。返回`view`里面所有的ToastView,如果没有则返回nil。
Expand Down
4 changes: 2 additions & 2 deletions QMUIKit/QMUIComponents/ToastView/QMUIToastView.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder {
return [self initWithView:nil];
}

- (instancetype)initWithView:(UIView *)view {
- (nonnull instancetype)initWithView:(nonnull UIView *)view {
NSAssert(view, @"view不能为空");
if (self = [super initWithFrame:view.bounds]) {
_parentView = view;
Expand Down Expand Up @@ -307,7 +307,7 @@ + (BOOL)hideAllToastInView:(UIView *)view animated:(BOOL)animated {
return returnFlag;
}

+ (instancetype)toastInView:(UIView *)view {
+ (nullable instancetype)toastInView:(UIView *)view {
NSEnumerator *subviewsEnum = [view.subviews reverseObjectEnumerator];
for (UIView *subview in subviewsEnum) {
if ([subview isKindOfClass:self]) {
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUIMainFrame/QMUICommonTableViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extern NSString *const QMUICommonTableViewControllerSectionFooterIdentifier;
@interface QMUICommonTableViewController : QMUICommonViewController<QMUITableViewDelegate, QMUITableViewDataSource>

- (instancetype)initWithStyle:(UITableViewStyle)style NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;

/**
* 初始化时调用的方法,会在两个 NS_DESIGNATED_INITIALIZER 方法中被调用,所以子类如果需要同时支持两个 NS_DESIGNATED_INITIALIZER 方法,则建议把初始化时要做的事情放到这个方法里。否则仅需重写要支持的那个 NS_DESIGNATED_INITIALIZER 方法即可。
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUIMainFrame/QMUICommonTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibB
return [self init];
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
if (self = [super initWithCoder:aDecoder]) {
[self didInitializeWithStyle:UITableViewStylePlain];
}
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUIMainFrame/QMUICommonViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@interface QMUICommonViewController : UIViewController<QMUINavigationControllerDelegate>

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;

/**
* 初始化时调用的方法,会在两个 NS_DESIGNATED_INITIALIZER 方法中被调用,所以子类如果需要同时支持两个 NS_DESIGNATED_INITIALIZER 方法,则建议把初始化时要做的事情放到这个方法里。否则仅需重写要支持的那个 NS_DESIGNATED_INITIALIZER 方法即可。
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUIMainFrame/QMUICommonViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibB
return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
if (self = [super initWithCoder:aDecoder]) {
[self didInitialize];
}
Expand Down

0 comments on commit 7b05d2d

Please sign in to comment.