From a47f7728a0f3dca2b68fb87d3a16dac46f1e8dab Mon Sep 17 00:00:00 2001 From: ibireme Date: Tue, 13 Sep 2016 17:47:26 +0800 Subject: [PATCH] fix Xcode8 warning --- Framework/YYText.xcodeproj/project.pbxproj | 10 +++++++--- .../xcshareddata/xcschemes/YYText.xcscheme | 2 +- YYText/Component/YYTextLayout.m | 1 - YYText/Component/YYTextLine.h | 6 +++--- YYText/Component/YYTextLine.m | 2 +- YYText/Utility/NSParagraphStyle+YYText.m | 6 ++++++ YYText/Utility/YYTextAsyncLayer.m | 2 +- YYText/YYLabel.m | 2 +- YYText/YYTextView.m | 2 +- 9 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Framework/YYText.xcodeproj/project.pbxproj b/Framework/YYText.xcodeproj/project.pbxproj index 0eba4002..37a7b2ae 100644 --- a/Framework/YYText.xcodeproj/project.pbxproj +++ b/Framework/YYText.xcodeproj/project.pbxproj @@ -315,7 +315,7 @@ D946DFD91BD2104E006B77F7 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = ibireme; TargetAttributes = { D946DFE11BD2104E006B77F7 = { @@ -398,8 +398,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -422,7 +424,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -445,8 +447,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -463,7 +467,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/Framework/YYText.xcodeproj/xcshareddata/xcschemes/YYText.xcscheme b/Framework/YYText.xcodeproj/xcshareddata/xcschemes/YYText.xcscheme index 4b70dc88..93d78e52 100644 --- a/Framework/YYText.xcodeproj/xcshareddata/xcschemes/YYText.xcscheme +++ b/Framework/YYText.xcodeproj/xcshareddata/xcschemes/YYText.xcscheme @@ -1,6 +1,6 @@ *attachments; ///< YYTextAttachment -@property (nonatomic, readonly) NSArray *attachmentRanges; ///< NSRange(NSValue) -@property (nonatomic, readonly) NSArray *attachmentRects; ///< CGRect(NSValue) +@property (nullable, nonatomic, readonly) NSArray *attachments; ///< YYTextAttachment +@property (nullable, nonatomic, readonly) NSArray *attachmentRanges; ///< NSRange(NSValue) +@property (nullable, nonatomic, readonly) NSArray *attachmentRects; ///< CGRect(NSValue) @end diff --git a/YYText/Component/YYTextLine.m b/YYText/Component/YYTextLine.m index 7c1d749d..09873835 100644 --- a/YYText/Component/YYTextLine.m +++ b/YYText/Component/YYTextLine.m @@ -30,7 +30,7 @@ - (void)dealloc { if (_CTLine) CFRelease(_CTLine); } -- (void)setCTLine:(CTLineRef)CTLine { +- (void)setCTLine:(_Nonnull CTLineRef)CTLine { if (_CTLine != CTLine) { if (CTLine) CFRetain(CTLine); if (_CTLine) CFRelease(_CTLine); diff --git a/YYText/Utility/NSParagraphStyle+YYText.m b/YYText/Utility/NSParagraphStyle+YYText.m index 0e595828..55e68915 100644 --- a/YYText/Utility/NSParagraphStyle+YYText.m +++ b/YYText/Utility/NSParagraphStyle+YYText.m @@ -25,10 +25,13 @@ + (NSParagraphStyle *)yy_styleWithCTStyle:(CTParagraphStyleRef)CTStyle { NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGFloat lineSpacing; if (CTParagraphStyleGetValueForSpecifier(CTStyle, kCTParagraphStyleSpecifierLineSpacing, sizeof(CGFloat), &lineSpacing)) { style.lineSpacing = lineSpacing; } +#pragma clang diagnostic pop CGFloat paragraphSpacing; if (CTParagraphStyleGetValueForSpecifier(CTStyle, kCTParagraphStyleSpecifierParagraphSpacing, sizeof(CGFloat), ¶graphSpacing)) { @@ -117,11 +120,14 @@ - (CTParagraphStyleRef)yy_CTStyle CF_RETURNS_RETAINED { CTParagraphStyleSetting set[kCTParagraphStyleSpecifierCount] = { 0 }; int count = 0; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGFloat lineSpacing = self.lineSpacing; set[count].spec = kCTParagraphStyleSpecifierLineSpacing; set[count].valueSize = sizeof(CGFloat); set[count].value = &lineSpacing; count++; +#pragma clang diagnostic pop CGFloat paragraphSpacing = self.paragraphSpacing; set[count].spec = kCTParagraphStyleSpecifierParagraphSpacing; diff --git a/YYText/Utility/YYTextAsyncLayer.m b/YYText/Utility/YYTextAsyncLayer.m index dd126d47..e94bc47e 100644 --- a/YYText/Utility/YYTextAsyncLayer.m +++ b/YYText/Utility/YYTextAsyncLayer.m @@ -117,7 +117,7 @@ - (void)display { #pragma mark - Private - (void)_displayAsync:(BOOL)async { - __strong id delegate = self.delegate; + __strong id delegate = (id)self.delegate; YYTextAsyncLayerDisplayTask *task = [delegate newAsyncDisplayTask]; if (!task.display) { if (task.willDisplay) task.willDisplay(self); diff --git a/YYText/YYLabel.m b/YYText/YYLabel.m index d3004dd2..f5656e9a 100644 --- a/YYText/YYLabel.m +++ b/YYText/YYLabel.m @@ -1156,7 +1156,7 @@ - (YYTextAsyncLayerDisplayTask *)newAsyncDisplayTask { } [layer removeAnimationForKey:@"contents"]; - YYLabel *view = layer.delegate; + __strong YYLabel *view = (YYLabel *)layer.delegate; if (!view) return; if (view->_state.layoutNeedUpdate && layoutUpdated) { view->_innerLayout = layout; diff --git a/YYText/YYTextView.m b/YYText/YYTextView.m index 3c3d6e31..ce5d3464 100644 --- a/YYText/YYTextView.m +++ b/YYText/YYTextView.m @@ -1073,7 +1073,7 @@ - (YYTextRange *)_getClosestTokenRangeAtPosition:(YYTextPosition *)position { } } - if (range.asRange.length == 0) { + if (!range || range.asRange.length == 0) { range = [_innerLayout textRangeByExtendingPosition:position inDirection:UITextLayoutDirectionRight offset:1]; range = [self _correctedTextRange:range]; if (range.asRange.length == 0) {