From ceca40bb06c776758cc44e62df491ae9db7491f3 Mon Sep 17 00:00:00 2001 From: Roman Podymov Date: Thu, 29 Jun 2023 15:17:03 +0200 Subject: [PATCH] Nullability (#1091) --- Examples/Objective-C/Podfile.lock | 6 +++--- .../InlineSegmentedCell/InlineSegmentedCell.swift | 2 +- XLForm/XL/NSArray+XLFormAdditions.h | 2 +- XLForm/XL/NSArray+XLFormAdditions.m | 2 +- XLForm/XL/NSExpression+XLFormAdditions.h | 2 +- XLForm/XL/NSExpression+XLFormAdditions.m | 4 +--- XLForm/XL/NSObject+XLFormAdditions.h | 4 ++-- XLForm/XL/NSObject+XLFormAdditions.m | 4 ++-- XLForm/XL/NSPredicate+XLFormAdditions.h | 2 +- XLForm/XL/NSPredicate+XLFormAdditions.m | 2 +- XLForm/XL/NSString+XLFormAdditions.h | 4 ++-- XLForm/XL/NSString+XLFormAdditions.m | 4 ++-- XLForm/XL/UIView+XLFormAdditions.h | 8 ++++---- XLForm/XL/UIView+XLFormAdditions.m | 8 ++++---- 14 files changed, 26 insertions(+), 28 deletions(-) diff --git a/Examples/Objective-C/Podfile.lock b/Examples/Objective-C/Podfile.lock index 0a609a3f..906962d1 100644 --- a/Examples/Objective-C/Podfile.lock +++ b/Examples/Objective-C/Podfile.lock @@ -43,7 +43,7 @@ PODS: - XLData/RemoteDataStore (2.0.0): - XLData/CoreRemote - XLData/DataStore - - XLForm (4.2.0) + - XLForm (4.3.0) DEPENDENCIES: - AFNetworking (~> 2.0) @@ -78,8 +78,8 @@ SPEC CHECKSUMS: JVFloatLabeledTextField: 58a3a32cfb800e5b224f676987e7c13abf50a14d SHSPhoneComponent: 4cec0653a150ad63cbc52b0c8b29ce2d3c9c26f0 XLData: df725c6179e2e0c80bf56a1ecad9afd169707a6d - XLForm: eb04ea4104f26250b70a72a7fa2eed3748dca5cd + XLForm: a439f9512078ed538e8335c8b06d3f3286bbfd37 PODFILE CHECKSUM: 64fbcd03a2c13762b2c18e3938cc8008807937c9 -COCOAPODS: 1.9.3 +COCOAPODS: 1.11.3 diff --git a/Examples/Swift/SwiftExample/CustomRows/InlineSegmentedCell/InlineSegmentedCell.swift b/Examples/Swift/SwiftExample/CustomRows/InlineSegmentedCell/InlineSegmentedCell.swift index e98f3a32..899b95a3 100644 --- a/Examples/Swift/SwiftExample/CustomRows/InlineSegmentedCell/InlineSegmentedCell.swift +++ b/Examples/Swift/SwiftExample/CustomRows/InlineSegmentedCell/InlineSegmentedCell.swift @@ -88,7 +88,7 @@ class InlineSegmentedControl : XLFormBaseCell, XLFormInlineRowDescriptorCell { var inlineRowDescriptor : XLFormRowDescriptor? lazy var segmentedControl : UISegmentedControl = { - return UISegmentedControl.autolayout()! + return UISegmentedControl.autolayout() }() override func configure() { diff --git a/XLForm/XL/NSArray+XLFormAdditions.h b/XLForm/XL/NSArray+XLFormAdditions.h index 9ae99440..7207aed5 100644 --- a/XLForm/XL/NSArray+XLFormAdditions.h +++ b/XLForm/XL/NSArray+XLFormAdditions.h @@ -27,6 +27,6 @@ @interface NSArray (XLFormAdditions) --(NSInteger)formIndexForItem:(id)item; +-(NSInteger)formIndexForItem:(nonnull id)item; @end diff --git a/XLForm/XL/NSArray+XLFormAdditions.m b/XLForm/XL/NSArray+XLFormAdditions.m index 28eda59e..434b3b63 100644 --- a/XLForm/XL/NSArray+XLFormAdditions.m +++ b/XLForm/XL/NSArray+XLFormAdditions.m @@ -28,7 +28,7 @@ @implementation NSArray (XLFormAdditions) --(NSInteger)formIndexForItem:(id)item +-(NSInteger)formIndexForItem:(nonnull id)item { for (id selectedValueItem in self) { if ([[selectedValueItem valueData] isEqual:[item valueData]]){ diff --git a/XLForm/XL/NSExpression+XLFormAdditions.h b/XLForm/XL/NSExpression+XLFormAdditions.h index 6052833a..28ed545d 100644 --- a/XLForm/XL/NSExpression+XLFormAdditions.h +++ b/XLForm/XL/NSExpression+XLFormAdditions.h @@ -28,6 +28,6 @@ @interface NSExpression (XLFormAdditions) --(NSMutableArray*) getExpressionVars; +-(nullable NSMutableArray*) getExpressionVars; @end diff --git a/XLForm/XL/NSExpression+XLFormAdditions.m b/XLForm/XL/NSExpression+XLFormAdditions.m index 55f7bcff..7e86139a 100644 --- a/XLForm/XL/NSExpression+XLFormAdditions.m +++ b/XLForm/XL/NSExpression+XLFormAdditions.m @@ -29,7 +29,7 @@ @implementation NSExpression (XLFormAdditions) --(NSMutableArray*) getExpressionVars{ +-(nullable NSMutableArray*) getExpressionVars{ switch (self.expressionType) { case NSFunctionExpressionType:{ NSString* str = [NSString stringWithFormat:@"%@", self]; @@ -38,11 +38,9 @@ -(NSMutableArray*) getExpressionVars{ else str = [str substringFromIndex:1]; return [[NSMutableArray alloc] initWithObjects: str, nil]; - break; } default: return nil; - break; } } diff --git a/XLForm/XL/NSObject+XLFormAdditions.h b/XLForm/XL/NSObject+XLFormAdditions.h index fd9fe246..49ff15fc 100644 --- a/XLForm/XL/NSObject+XLFormAdditions.h +++ b/XLForm/XL/NSObject+XLFormAdditions.h @@ -27,7 +27,7 @@ @interface NSObject (XLFormAdditions) --(NSString *)displayText; --(id)valueData; +-(nullable NSString *)displayText; +-(nullable id)valueData; @end diff --git a/XLForm/XL/NSObject+XLFormAdditions.m b/XLForm/XL/NSObject+XLFormAdditions.m index 13b6214e..78e2420d 100644 --- a/XLForm/XL/NSObject+XLFormAdditions.m +++ b/XLForm/XL/NSObject+XLFormAdditions.m @@ -29,7 +29,7 @@ @implementation NSObject (XLFormAdditions) --(NSString *)displayText +-(nullable NSString *)displayText { if ([self conformsToProtocol:@protocol(XLFormOptionObject)]){ return [(id)self formDisplayText]; @@ -40,7 +40,7 @@ -(NSString *)displayText return nil; } --(id)valueData +-(nullable id)valueData { if ([self isKindOfClass:[NSString class]] || [self isKindOfClass:[NSNumber class]] || [self isKindOfClass:[NSDate class]]){ return self; diff --git a/XLForm/XL/NSPredicate+XLFormAdditions.h b/XLForm/XL/NSPredicate+XLFormAdditions.h index 181a2b84..107f04b1 100644 --- a/XLForm/XL/NSPredicate+XLFormAdditions.h +++ b/XLForm/XL/NSPredicate+XLFormAdditions.h @@ -27,5 +27,5 @@ @interface NSPredicate (XLFormAdditions) --(NSMutableArray*) getPredicateVars; +-(nonnull NSMutableArray*) getPredicateVars; @end diff --git a/XLForm/XL/NSPredicate+XLFormAdditions.m b/XLForm/XL/NSPredicate+XLFormAdditions.m index 75fa9adc..625a8661 100644 --- a/XLForm/XL/NSPredicate+XLFormAdditions.m +++ b/XLForm/XL/NSPredicate+XLFormAdditions.m @@ -28,7 +28,7 @@ @implementation NSPredicate (XLFormAdditions) --(NSMutableArray*) getPredicateVars{ +-(nonnull NSMutableArray*) getPredicateVars{ NSMutableArray* ret = [[NSMutableArray alloc] init]; if ([self isKindOfClass:([NSCompoundPredicate class])]) { for (id object in ((NSCompoundPredicate*) self).subpredicates ) { diff --git a/XLForm/XL/NSString+XLFormAdditions.h b/XLForm/XL/NSString+XLFormAdditions.h index 7cdc14b0..f9711687 100644 --- a/XLForm/XL/NSString+XLFormAdditions.h +++ b/XLForm/XL/NSString+XLFormAdditions.h @@ -28,8 +28,8 @@ @interface NSString (XLFormAdditions) --(NSPredicate *)formPredicate; +-(nonnull NSPredicate *)formPredicate; --(NSString *)formKeyForPredicateType:(XLPredicateType)predicateType; +-(nonnull NSString *)formKeyForPredicateType:(XLPredicateType)predicateType; @end diff --git a/XLForm/XL/NSString+XLFormAdditions.m b/XLForm/XL/NSString+XLFormAdditions.m index 9f8bd5b4..3bb37f09 100644 --- a/XLForm/XL/NSString+XLFormAdditions.m +++ b/XLForm/XL/NSString+XLFormAdditions.m @@ -27,7 +27,7 @@ @implementation NSString (XLFormAdditions) --(NSPredicate *)formPredicate +-(nonnull NSPredicate *)formPredicate { // returns an array of strings where the first one is the new string with the correct replacements // and the rest are all the tags that appear in the string @@ -57,7 +57,7 @@ -(NSPredicate *)formPredicate } --(NSString *)formKeyForPredicateType:(XLPredicateType)predicateType +-(nonnull NSString *)formKeyForPredicateType:(XLPredicateType)predicateType { return [NSString stringWithFormat:@"%@-%@", self, (predicateType == XLPredicateTypeHidden ? @"hidden" : @"disabled") ]; } diff --git a/XLForm/XL/UIView+XLFormAdditions.h b/XLForm/XL/UIView+XLFormAdditions.h index 34c1cef6..f26ff43b 100644 --- a/XLForm/XL/UIView+XLFormAdditions.h +++ b/XLForm/XL/UIView+XLFormAdditions.h @@ -28,9 +28,9 @@ @interface UIView (XLFormAdditions) -+(instancetype)autolayoutView; --(NSLayoutConstraint *)layoutConstraintSameHeightOf:(UIView *)view; --(UIView *)findFirstResponder; --(UITableViewCell *)formDescriptorCell; ++(nonnull instancetype)autolayoutView; +-(nonnull NSLayoutConstraint *)layoutConstraintSameHeightOf:(nonnull UIView *)view; +-(nullable UIView *)findFirstResponder; +-(nullable UITableViewCell *)formDescriptorCell; @end diff --git a/XLForm/XL/UIView+XLFormAdditions.m b/XLForm/XL/UIView+XLFormAdditions.m index c2bc45a6..678616b1 100644 --- a/XLForm/XL/UIView+XLFormAdditions.m +++ b/XLForm/XL/UIView+XLFormAdditions.m @@ -27,7 +27,7 @@ @implementation UIView (XLFormAdditions) -+ (instancetype)autolayoutView ++ (nonnull instancetype)autolayoutView { __kindof UIView *view = [self new]; view.translatesAutoresizingMaskIntoConstraints = NO; @@ -35,7 +35,7 @@ + (instancetype)autolayoutView return view; } -- (NSLayoutConstraint *)layoutConstraintSameHeightOf:(UIView *)view +- (nonnull NSLayoutConstraint *)layoutConstraintSameHeightOf:(nonnull UIView *)view { return [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeHeight @@ -46,7 +46,7 @@ - (NSLayoutConstraint *)layoutConstraintSameHeightOf:(UIView *)view constant:0.0]; } -- (UIView *)findFirstResponder +- (nullable UIView *)findFirstResponder { UIView *firstResponder = nil; if (self.isFirstResponder) { @@ -66,7 +66,7 @@ - (UIView *)findFirstResponder return firstResponder; } -- (UITableViewCell *)formDescriptorCell +- (nullable UITableViewCell *)formDescriptorCell { UITableViewCell * tableViewCell = nil;