diff --git a/Masonry/MASCompositeConstraint.h b/Masonry/MASCompositeConstraint.h index 934c6f16..fa255020 100644 --- a/Masonry/MASCompositeConstraint.h +++ b/Masonry/MASCompositeConstraint.h @@ -14,6 +14,8 @@ */ @interface MASCompositeConstraint : MASConstraint +NS_ASSUME_NONNULL_BEGIN + /** * Creates a composite with a predefined array of children * @@ -21,6 +23,8 @@ * * @return a composite constraint */ -- (id)initWithChildren:(NSArray *)children; +- (instancetype)initWithChildren:(NSArray *)children; + +NS_ASSUME_NONNULL_END @end diff --git a/Masonry/MASCompositeConstraint.m b/Masonry/MASCompositeConstraint.m index 2002a405..6464b174 100644 --- a/Masonry/MASCompositeConstraint.m +++ b/Masonry/MASCompositeConstraint.m @@ -18,9 +18,9 @@ @interface MASCompositeConstraint () @implementation MASCompositeConstraint -- (id)initWithChildren:(NSArray *)children { +- (instancetype)initWithChildren:(NSArray *)children { self = [super init]; - if (!self) return nil; + if (!self) return self; _childConstraints = [children mutableCopy]; for (MASConstraint *constraint in _childConstraints) { diff --git a/Masonry/MASConstraint+Private.h b/Masonry/MASConstraint+Private.h index ee0fd960..faf4de3d 100644 --- a/Masonry/MASConstraint+Private.h +++ b/Masonry/MASConstraint+Private.h @@ -13,6 +13,8 @@ @interface MASConstraint () +NS_ASSUME_NONNULL_BEGIN + /** * Whether or not to check for an existing constraint instead of adding constraint */ @@ -21,7 +23,7 @@ /** * Usually MASConstraintMaker but could be a parent MASConstraint */ -@property (nonatomic, weak) id delegate; +@property (nullable, nonatomic, weak) id delegate; /** * Based on a provided value type, is equal to calling: @@ -32,11 +34,15 @@ */ - (void)setLayoutConstantWithValue:(NSValue *)value; +NS_ASSUME_NONNULL_END + @end @interface MASConstraint (Abstract) +NS_ASSUME_NONNULL_BEGIN + /** * Sets the constraint relation to given NSLayoutRelation * returns a block which accepts one of the following: @@ -50,17 +56,23 @@ */ - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; +NS_ASSUME_NONNULL_END + @end @protocol MASConstraintDelegate +NS_ASSUME_NONNULL_BEGIN + /** * Notifies the delegate when the constraint needs to be replaced with another constraint. For example * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks */ - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint; -- (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; +- (MASConstraint *)constraint:(nullable MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; + +NS_ASSUME_NONNULL_END @end diff --git a/Masonry/MASConstraint.h b/Masonry/MASConstraint.h index 6fea79ee..f06e929e 100644 --- a/Masonry/MASConstraint.h +++ b/Masonry/MASConstraint.h @@ -15,6 +15,8 @@ */ @interface MASConstraint : NSObject +NS_ASSUME_NONNULL_BEGIN + // Chaining Support /** @@ -223,6 +225,8 @@ */ - (void)uninstall; +NS_ASSUME_NONNULL_END + @end @@ -252,6 +256,8 @@ @interface MASConstraint (AutoboxingSupport) +NS_ASSUME_NONNULL_BEGIN + /** * Aliases to corresponding relation methods (for shorthand macros) * Also needed to aid autocompletion @@ -265,4 +271,6 @@ */ - (MASConstraint * (^)(id offset))mas_offset; +NS_ASSUME_NONNULL_END + @end diff --git a/Masonry/MASConstraint.m b/Masonry/MASConstraint.m index b8841e58..3a5ad368 100644 --- a/Masonry/MASConstraint.m +++ b/Masonry/MASConstraint.m @@ -17,7 +17,7 @@ @implementation MASConstraint #pragma mark - Init -- (id)init { +- (instancetype)init { NSAssert(![self isMemberOfClass:[MASConstraint class]], @"MASConstraint is an abstract class, you should not instantiate it directly."); return [super init]; } diff --git a/Masonry/MASConstraintMaker.h b/Masonry/MASConstraintMaker.h index 9a0bc8df..6034524d 100644 --- a/Masonry/MASConstraintMaker.h +++ b/Masonry/MASConstraintMaker.h @@ -47,6 +47,8 @@ typedef NS_OPTIONS(NSInteger, MASAttribute) { */ @interface MASConstraintMaker : NSObject +NS_ASSUME_NONNULL_BEGIN + /** * The following properties return a new MASViewConstraint * with the first item set to the makers associated view and the appropriate MASViewAttribute @@ -124,7 +126,7 @@ typedef NS_OPTIONS(NSInteger, MASAttribute) { * * @return a new MASConstraintMaker */ -- (id)initWithView:(MAS_VIEW *)view; +- (instancetype)initWithView:(MAS_VIEW *)view; /** * Calls install method on any MASConstraints which have been created by this maker @@ -135,4 +137,6 @@ typedef NS_OPTIONS(NSInteger, MASAttribute) { - (MASConstraint * (^)(dispatch_block_t))group; +NS_ASSUME_NONNULL_END + @end diff --git a/Masonry/MASConstraintMaker.m b/Masonry/MASConstraintMaker.m index 26d377be..d6c6b962 100644 --- a/Masonry/MASConstraintMaker.m +++ b/Masonry/MASConstraintMaker.m @@ -22,9 +22,9 @@ @interface MASConstraintMaker () @implementation MASConstraintMaker -- (id)initWithView:(MAS_VIEW *)view { +- (instancetype)initWithView:(MAS_VIEW *)view { self = [super init]; - if (!self) return nil; + if (!self) return self; self.view = view; self.constraints = NSMutableArray.new; diff --git a/Masonry/MASLayoutConstraint.h b/Masonry/MASLayoutConstraint.h index 699041cb..0faf8e84 100644 --- a/Masonry/MASLayoutConstraint.h +++ b/Masonry/MASLayoutConstraint.h @@ -14,9 +14,13 @@ */ @interface MASLayoutConstraint : NSLayoutConstraint +NS_ASSUME_NONNULL_BEGIN + /** * a key to associate with this constraint */ @property (nonatomic, strong) id mas_key; +NS_ASSUME_NONNULL_END + @end diff --git a/Masonry/MASViewAttribute.h b/Masonry/MASViewAttribute.h index 601c25d1..6a8a2b7e 100644 --- a/Masonry/MASViewAttribute.h +++ b/Masonry/MASViewAttribute.h @@ -14,15 +14,17 @@ */ @interface MASViewAttribute : NSObject +NS_ASSUME_NONNULL_BEGIN + /** * The view which the reciever relates to. Can be nil if item is not a view. */ -@property (nonatomic, weak, readonly) MAS_VIEW *view; +@property (nullable, nonatomic, weak, readonly) MAS_VIEW *view; /** * The item which the reciever relates to. */ -@property (nonatomic, weak, readonly) id item; +@property (nullable, nonatomic, weak, readonly) id item; /** * The attribute which the reciever relates to @@ -32,12 +34,12 @@ /** * Convenience initializer. */ -- (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; +- (instancetype)initWithView:(nullable MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; /** * The designated initializer. */ -- (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute; +- (instancetype)initWithView:(nullable MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute; /** * Determine whether the layoutAttribute is a size attribute @@ -46,4 +48,6 @@ */ - (BOOL)isSizeAttribute; +NS_ASSUME_NONNULL_END + @end diff --git a/Masonry/MASViewAttribute.m b/Masonry/MASViewAttribute.m index e573e8bd..d10d254b 100644 --- a/Masonry/MASViewAttribute.m +++ b/Masonry/MASViewAttribute.m @@ -10,14 +10,14 @@ @implementation MASViewAttribute -- (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute { +- (instancetype)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute { self = [self initWithView:view item:view layoutAttribute:layoutAttribute]; return self; } -- (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute { +- (instancetype)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute { self = [super init]; - if (!self) return nil; + if (!self) return self; _view = view; _item = item; diff --git a/Masonry/MASViewConstraint.h b/Masonry/MASViewConstraint.h index ec390d15..2da216c7 100644 --- a/Masonry/MASViewConstraint.h +++ b/Masonry/MASViewConstraint.h @@ -17,6 +17,8 @@ */ @interface MASViewConstraint : MASConstraint +NS_ASSUME_NONNULL_BEGIN + /** * First item/view and first attribute of the NSLayoutConstraint */ @@ -34,7 +36,7 @@ * * @return a new view constraint */ -- (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute; +- (instancetype)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute; /** * Returns all MASViewConstraints installed with this view as a first item. @@ -45,4 +47,6 @@ */ + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view; +NS_ASSUME_NONNULL_END + @end diff --git a/Masonry/MASViewConstraint.m b/Masonry/MASViewConstraint.m index af3f0b44..10860a04 100644 --- a/Masonry/MASViewConstraint.m +++ b/Masonry/MASViewConstraint.m @@ -52,9 +52,9 @@ @interface MASViewConstraint () @implementation MASViewConstraint -- (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute { +- (instancetype)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute { self = [super init]; - if (!self) return nil; + if (!self) return self; _firstViewAttribute = firstViewAttribute; self.layoutPriority = MASLayoutPriorityRequired; @@ -65,7 +65,7 @@ - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute { #pragma mark - NSCoping -- (id)copyWithZone:(NSZone __unused *)zone { +- (instancetype)copyWithZone:(NSZone __unused *)zone { MASViewConstraint *constraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:self.firstViewAttribute]; constraint.layoutConstant = self.layoutConstant; constraint.layoutRelation = self.layoutRelation; diff --git a/Masonry/NSArray+MASAdditions.h b/Masonry/NSArray+MASAdditions.h index 587618d9..bb2f69ca 100644 --- a/Masonry/NSArray+MASAdditions.h +++ b/Masonry/NSArray+MASAdditions.h @@ -17,6 +17,8 @@ typedef NS_ENUM(NSUInteger, MASAxisType) { @interface NSArray (MASAdditions) +NS_ASSUME_NONNULL_BEGIN + /** * Creates a MASConstraintMaker with each view in the callee. * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view @@ -69,4 +71,6 @@ typedef NS_ENUM(NSUInteger, MASAxisType) { */ - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; +NS_ASSUME_NONNULL_END + @end diff --git a/Masonry/NSArray+MASShorthandAdditions.h b/Masonry/NSArray+MASShorthandAdditions.h index 8b473697..18e2d6dd 100644 --- a/Masonry/NSArray+MASShorthandAdditions.h +++ b/Masonry/NSArray+MASShorthandAdditions.h @@ -16,10 +16,14 @@ */ @interface NSArray (MASShorthandAdditions) +NS_ASSUME_NONNULL_BEGIN + - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; +NS_ASSUME_NONNULL_END + @end @implementation NSArray (MASShorthandAdditions) diff --git a/Masonry/View+MASAdditions.h b/Masonry/View+MASAdditions.h index 00477c1c..7651bf26 100644 --- a/Masonry/View+MASAdditions.h +++ b/Masonry/View+MASAdditions.h @@ -16,6 +16,8 @@ */ @interface MAS_VIEW (MASAdditions) +NS_ASSUME_NONNULL_BEGIN + /** * following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute */ @@ -72,7 +74,7 @@ * * @return returns nil if common superview could not be found */ -- (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; +- (nullable instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; /** * Creates a MASConstraintMaker with the callee view. @@ -106,4 +108,6 @@ */ - (NSArray *)mas_remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; +NS_ASSUME_NONNULL_END + @end diff --git a/Masonry/View+MASShorthandAdditions.h b/Masonry/View+MASShorthandAdditions.h index 8e375ee3..6fddae77 100644 --- a/Masonry/View+MASShorthandAdditions.h +++ b/Masonry/View+MASShorthandAdditions.h @@ -16,6 +16,8 @@ */ @interface MAS_VIEW (MASShorthandAdditions) +NS_ASSUME_NONNULL_BEGIN + @property (nonatomic, strong, readonly) MASViewAttribute *left; @property (nonatomic, strong, readonly) MASViewAttribute *top; @property (nonatomic, strong, readonly) MASViewAttribute *right; @@ -64,6 +66,8 @@ - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; +NS_ASSUME_NONNULL_END + @end #define MAS_ATTR_FORWARD(attr) \ diff --git a/Masonry/ViewController+MASAdditions.h b/Masonry/ViewController+MASAdditions.h index 564654af..e1a38a4b 100644 --- a/Masonry/ViewController+MASAdditions.h +++ b/Masonry/ViewController+MASAdditions.h @@ -14,6 +14,8 @@ @interface MAS_VIEW_CONTROLLER (MASAdditions) +NS_ASSUME_NONNULL_BEGIN + /** * following properties return a new MASViewAttribute with appropriate UILayoutGuide and NSLayoutAttribute */ @@ -24,6 +26,8 @@ @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideTop NS_DEPRECATED_IOS(8.0, 11.0); @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideBottom NS_DEPRECATED_IOS(8.0, 11.0); +NS_ASSUME_NONNULL_END + @end #endif