Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
29af51f
Aztec is now Swift 4 Friendly. Mark I
jleandroperez Nov 6, 2017
37e62a9
Aztec is now Swift 4 Friendly. Mark II
jleandroperez Nov 6, 2017
b73664d
Disabling Swift3 ObjC Inference
jleandroperez Nov 6, 2017
70b8314
Aztec is now Swift 4 Friendly. Mark III
jleandroperez Nov 6, 2017
1f6f014
Merge remote-tracking branch 'origin/develop' into issue/807-swift-4-…
jleandroperez Nov 6, 2017
5964f32
EditorDemoController: Fixing Font Weight
jleandroperez Nov 6, 2017
3707f9f
TextView: @diegoreymendez is a genius
jleandroperez Nov 6, 2017
4971cc7
Disabling Swift3 ObjC Inference / Testing Target
jleandroperez Nov 6, 2017
f418fd0
Disabling Swift3 ObjC Inference / Example Target
jleandroperez Nov 6, 2017
523ba08
Swift 4: replacing substring(to:) with prefix(upTo:)
jleandroperez Nov 6, 2017
c1dc7d2
Swift 4: replacing .substring(with:) with subscript operators
jleandroperez Nov 6, 2017
cca5084
Swift 4: replacing substring(from:) with subscript operators
jleandroperez Nov 6, 2017
e0cb393
Implements NSAttributedStringKey+Aztec
jleandroperez Nov 6, 2017
12aaa5b
TextView: Cleanup
jleandroperez Nov 6, 2017
9c18636
Merge remote-tracking branch 'origin/develop' into issue/807-swift-4-…
jleandroperez Nov 7, 2017
cd449e5
NSAttributedStringKey: Renames constant
jleandroperez Nov 7, 2017
2396986
NSAttributedStringKey+Conversion: Documenting Methods
jleandroperez Nov 7, 2017
0b51bee
Implements NSAttributedStringKeyHelperTests
jleandroperez Nov 7, 2017
09c7973
Cocoapods Swift Version: Mark 4.0
jleandroperez Nov 7, 2017
8eaf6bc
NSAttributedStringKey+Aztec: Removing 1 line here
jleandroperez Nov 7, 2017
02bea21
NSAttributedStringKey+Aztec: Removing another line here
jleandroperez Nov 7, 2017
afd7e3b
String+RangeConversion: fatalError FTW
jleandroperez Nov 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2
4.0
40 changes: 30 additions & 10 deletions Aztec.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
B542D6421E9EB122009D12D3 /* PreFormaterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B542D6411E9EB122009D12D3 /* PreFormaterTests.swift */; };
B551A4A01E770B3800EE3A7F /* UIFont+Emoji.swift in Sources */ = {isa = PBXBuildFile; fileRef = B551A49F1E770B3800EE3A7F /* UIFont+Emoji.swift */; };
B572AC281E817CFE008948C2 /* CommentAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = B572AC271E817CFE008948C2 /* CommentAttachment.swift */; };
B574F4A41FB0CF3B0048F355 /* NSAttributedStringKey+Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = B574F4A31FB0CF3A0048F355 /* NSAttributedStringKey+Conversion.swift */; };
B574F4AD1FB103430048F355 /* NSAttributedStringKey+Aztec.swift in Sources */ = {isa = PBXBuildFile; fileRef = B574F4AC1FB103430048F355 /* NSAttributedStringKey+Aztec.swift */; };
B574F4AF1FB110850048F355 /* NSAttributedStringKeyHelperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B574F4AE1FB110850048F355 /* NSAttributedStringKeyHelperTests.swift */; };
B57534501F267D0B009D4904 /* Array+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = B575344F1F267D0B009D4904 /* Array+Helpers.swift */; };
B57534521F267D63009D4904 /* ArrayHelperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B57534511F267D63009D4904 /* ArrayHelperTests.swift */; };
B57D1C3D1E92C38000EA4B16 /* HTMLAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = B57D1C3C1E92C38000EA4B16 /* HTMLAttachment.swift */; };
Expand Down Expand Up @@ -219,6 +222,9 @@
B542D6411E9EB122009D12D3 /* PreFormaterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreFormaterTests.swift; sourceTree = "<group>"; };
B551A49F1E770B3800EE3A7F /* UIFont+Emoji.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIFont+Emoji.swift"; sourceTree = "<group>"; };
B572AC271E817CFE008948C2 /* CommentAttachment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommentAttachment.swift; sourceTree = "<group>"; };
B574F4A31FB0CF3A0048F355 /* NSAttributedStringKey+Conversion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSAttributedStringKey+Conversion.swift"; sourceTree = "<group>"; };
B574F4AC1FB103430048F355 /* NSAttributedStringKey+Aztec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSAttributedStringKey+Aztec.swift"; sourceTree = "<group>"; };
B574F4AE1FB110850048F355 /* NSAttributedStringKeyHelperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = NSAttributedStringKeyHelperTests.swift; path = Extensions/NSAttributedStringKeyHelperTests.swift; sourceTree = "<group>"; };
B575344F1F267D0B009D4904 /* Array+Helpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Array+Helpers.swift"; sourceTree = "<group>"; };
B57534511F267D63009D4904 /* ArrayHelperTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ArrayHelperTests.swift; path = Extensions/ArrayHelperTests.swift; sourceTree = "<group>"; };
B57D1C3C1E92C38000EA4B16 /* HTMLAttachment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTMLAttachment.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -484,6 +490,7 @@
children = (
599F25201D8BC9A1002871D6 /* HTMLConstants.swift */,
599F25211D8BC9A1002871D6 /* Metrics.swift */,
B574F4AC1FB103430048F355 /* NSAttributedStringKey+Aztec.swift */,
);
path = Constants;
sourceTree = "<group>";
Expand All @@ -502,6 +509,7 @@
B5BC4FED1DA2C17800614582 /* NSAttributedString+Lists.swift */,
F10BE6191EA7AE9D002E4625 /* NSAttributedString+ReplaceOcurrences.swift */,
B50CE7311F1FA6260018CAA1 /* NSAttributedString+Strip.swift */,
B574F4A31FB0CF3A0048F355 /* NSAttributedStringKey+Conversion.swift */,
FFD0FEB61DAE59A700430586 /* NSLayoutManager+Attachments.swift */,
F10BE6171EA7ADA6002E4625 /* NSMutableAttributedString+ReplaceOcurrences.swift */,
F18733C41DA096EE005AEB80 /* NSRange+Helpers.swift */,
Expand Down Expand Up @@ -774,6 +782,7 @@
B5BC4FF11DA2D17000614582 /* NSAttributedStringListsTests.swift */,
F10BE61B1EA7B1DB002E4625 /* NSAttributedStringReplaceOcurrencesTests.swift */,
F17BC8741F4E48FF00398E2B /* NSAttributedStringHTMLInitializerTests.swift */,
B574F4AE1FB110850048F355 /* NSAttributedStringKeyHelperTests.swift */,
F14665441EA7C230008DE2B8 /* NSMutableAttributedStringReplaceOcurrencesTests.swift */,
F18733C71DA09737005AEB80 /* NSRangeComparisonTests.swift */,
F1000CE81EAA5C720000B15B /* StringEndOfLineTests.swift */,
Expand Down Expand Up @@ -910,12 +919,12 @@
5951CB8D1D8BC93600E1866F = {
CreatedOnToolsVersion = 8.0;
DevelopmentTeam = PZYM8XX95Q;
LastSwiftMigration = 0810;
LastSwiftMigration = 0910;
ProvisioningStyle = Manual;
};
5951CB961D8BC93600E1866F = {
CreatedOnToolsVersion = 8.0;
LastSwiftMigration = 0820;
LastSwiftMigration = 0910;
ProvisioningStyle = Automatic;
};
E8CE3EFE1F213AAA003254AB = {
Expand Down Expand Up @@ -995,6 +1004,7 @@
B5C99D3F1E72E2E700335355 /* UIStackView+Helpers.swift in Sources */,
F1C05B991E37F99D007510EA /* Character+Name.swift in Sources */,
FF20D6421EDC389A00294B78 /* Processor.swift in Sources */,
B574F4AD1FB103430048F355 /* NSAttributedStringKey+Aztec.swift in Sources */,
599F253B1D8BC9A1002871D6 /* InNodesConverter.swift in Sources */,
F18B81EB1EA5601000885F43 /* StringUnicodeScalarView+RangeConversion.swift in Sources */,
F127F7141F0591AD008A00D7 /* CSSAttribute.swift in Sources */,
Expand All @@ -1006,6 +1016,7 @@
599F254F1D8BC9A1002871D6 /* FormatBarItem.swift in Sources */,
F17BC8931F4E4BA500398E2B /* HTMLRepresentation.swift in Sources */,
F18B81ED1EA560B700885F43 /* StringUTF16+RangeConversion.swift in Sources */,
B574F4A41FB0CF3B0048F355 /* NSAttributedStringKey+Conversion.swift in Sources */,
F12F58631EF20394008AE298 /* AttributeFormatter.swift in Sources */,
F19544051F588F1A00671B73 /* CSSParser.swift in Sources */,
599F254E1D8BC9A1002871D6 /* FormatBarDelegate.swift in Sources */,
Expand Down Expand Up @@ -1103,6 +1114,7 @@
F1953E251F4E544A00C717C9 /* HTMLParserTests.swift in Sources */,
B5C16A631F4DF77300B113CF /* HeaderFormatterTests.swift in Sources */,
B5D575881F2288E2003A62F6 /* TextViewStubAttachmentDelegate.swift in Sources */,
B574F4AF1FB110850048F355 /* NSAttributedStringKeyHelperTests.swift in Sources */,
F168DB861F6381A00009BD0E /* CSSParserTests.swift in Sources */,
F1000CE91EAA5C720000B15B /* StringEndOfLineTests.swift in Sources */,
F17BC8751F4E48FF00398E2B /* NSAttributedStringHTMLInitializerTests.swift in Sources */,
Expand Down Expand Up @@ -1267,7 +1279,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "$(PROJECT_DIR)/Aztec/Modulemaps/libxml2";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
Expand Down Expand Up @@ -1295,7 +1308,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "$(PROJECT_DIR)/Aztec/Modulemaps/libxml2";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
Expand All @@ -1315,7 +1329,8 @@
PRODUCT_BUNDLE_IDENTIFIER = com.wordpress.AztecTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1333,7 +1348,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.wordpress.AztecTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down Expand Up @@ -1462,7 +1478,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "$(PROJECT_DIR)/Aztec/Modulemaps/libxml2";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Profiling;
Expand All @@ -1481,7 +1498,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.wordpress.AztecTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
};
name = Profiling;
};
Expand Down Expand Up @@ -1569,7 +1587,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "$(PROJECT_DIR)/Aztec/Modulemaps/libxml2";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = "Release-Alpha";
Expand All @@ -1589,7 +1608,8 @@
PRODUCT_BUNDLE_IDENTIFIER = com.wordpress.AztecTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
};
name = "Release-Alpha";
};
Expand Down
46 changes: 46 additions & 0 deletions Aztec/Classes/Constants/NSAttributedStringKey+Aztec.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import Foundation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really important, but remove 1 line here.

// MARK: - Aztec NSAttributedString Keys
//
public extension NSAttributedStringKey {

/// Key used to store Bold Tag Metadata, by our BoldFormatter.
///
public static let boldHtmlRepresentation = NSAttributedStringKey("Bold.htmlRepresentation")

/// Key used to store Color Tags Metadata, by our ColorFormatter.
///
public static let colorHtmlRepresentation = NSAttributedStringKey("Color.htmlRepresentation")

/// Key used to store HR Tag Metadata, by our HRFormatter.
///
public static let hrHtmlRepresentation = NSAttributedStringKey("HR.htmlRepresentation")

/// Key used to store Image Tag Metadata, by our ImageFormatter.
///
public static let imageHtmlRepresentation = NSAttributedStringKey("Image.htmlRepresentation")

/// Key used to store Italics Tag Metadata, by our ItalicFormatter.
///
public static let italicHtmlRepresentation = NSAttributedStringKey("Italic.htmlRepresentation")

/// Key used to store Link Tag Metadata, by our LinkFormatter.
///
public static let linkHtmlRepresentation = NSAttributedStringKey("Link.htmlRepresentation")

/// Key used to store Strike Tag Metadata, by our StrikeFormatter.
///
public static let strikethroughHtmlRepresentation = NSAttributedStringKey("Strike.htmlRepresentation")

/// Key used to store UnderlineHTMLRepresentations, by our UnderlineFormatter.
///
public static let underlineHtmlRepresentation = NSAttributedStringKey("Underline.htmlRepresentation")

/// Key used to store UnsupportedHTML Snippets, by our HTML Parser.
///
public static let unsupportedHtml = NSAttributedStringKey("UnsupportedHTMLAttributeName")

/// Key used to store VideoHTMLRepresentations, by our VideoFormatter.
///
public static let videoHtmlRepresentation = NSAttributedStringKey("Video.htmlRepresentation")
}
4 changes: 2 additions & 2 deletions Aztec/Classes/Extensions/NSAttributedString+Analyzers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension NSAttributedString {
return false
}

return attribute(NSLinkAttributeName, at: beforeRange.location, effectiveRange: nil) != nil
return attribute(.link, at: beforeRange.location, effectiveRange: nil) != nil
}

/// Returns true if the text immediately succeding a given location contains the NSLinkAttribute.
Expand All @@ -25,7 +25,7 @@ extension NSAttributedString {
return false
}

return attribute(NSLinkAttributeName, at: afterRange.location, effectiveRange: nil) != nil
return attribute(.link, at: afterRange.location, effectiveRange: nil) != nil
}

/// Returns the Substring at the specified range, whenever the received range is valid, or nil
Expand Down
8 changes: 4 additions & 4 deletions Aztec/Classes/Extensions/NSAttributedString+Attachments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ extension NSAttributedString
/// Helper Initializer: returns an Attributed String, with the specified attachment, styled with a given
/// collection of attributes.
///
convenience init(attachment: NSTextAttachment, attributes: [String: Any]) {
convenience init(attachment: NSTextAttachment, attributes: [NSAttributedStringKey: Any]) {
var attributesWithAttachment = attributes
attributesWithAttachment[NSAttachmentAttributeName] = attachment
attributesWithAttachment[.attachment] = attachment

self.init(string: NSAttributedString.textAttachmentString, attributes: attributesWithAttachment)
}
Expand Down Expand Up @@ -52,7 +52,7 @@ extension NSAttributedString
///
func enumerateAttachmentsOfType<T : NSTextAttachment>(_ type: T.Type, range: NSRange? = nil, block: ((T, NSRange, UnsafeMutablePointer<ObjCBool>) -> Void)) {
let range = range ?? NSMakeRange(0, length)
enumerateAttribute(NSAttachmentAttributeName, in: range, options: []) { (object, range, stop) in
enumerateAttribute(.attachment, in: range, options: []) { (object, range, stop) in
if let object = object as? T {
block(object, range, stop)
}
Expand All @@ -69,7 +69,7 @@ extension NSAttributedString
public func ranges(forAttachment attachment: NSTextAttachment) -> [NSRange] {
let range = NSRange(location: 0, length: length)
var attachmentRanges = [NSRange]()
enumerateAttribute(NSAttachmentAttributeName, in: range, options: []) { (value, effectiveRange, nil) in
enumerateAttribute(.attachment, in: range, options: []) { (value, effectiveRange, nil) in
guard let foundAttachment = value as? NSTextAttachment, foundAttachment == attachment else {
return
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

extension NSAttributedString {
convenience init(_ characterName: Character.Name, attributes: [String:Any]?) {
convenience init(_ characterName: Character.Name, attributes: [NSAttributedStringKey: Any]?) {
self.init(string: String(characterName), attributes: attributes)
}
}
10 changes: 5 additions & 5 deletions Aztec/Classes/Extensions/NSAttributedString+FontTraits.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public extension NSAttributedString {
/// - Returns: True if found.
///
public func fontTrait(_ traits: UIFontDescriptorSymbolicTraits, existsAtIndex index: Int) -> Bool {
guard let attr = attribute(NSFontAttributeName, at: index, effectiveRange: nil) else {
guard let attr = attribute(.font, at: index, effectiveRange: nil) else {
return false
}
if let font = attr as? UIFont {
Expand All @@ -37,7 +37,7 @@ public extension NSAttributedString {
var spansRange = true

// Assume we're removing the trait. If the trait is missing anywhere in the range assign it.
enumerateAttribute(NSFontAttributeName,
enumerateAttribute(.font,
in: range,
options: [],
using: { (object: Any?, range: NSRange, stop: UnsafeMutablePointer<ObjCBool>) in
Expand Down Expand Up @@ -75,7 +75,7 @@ public extension NSMutableAttributedString {

fileprivate func modify(_ fontTraits: UIFontDescriptorSymbolicTraits, range: NSRange, enable: Bool) {

enumerateAttribute(NSFontAttributeName,
enumerateAttribute(.font,
in: range,
options: [],
using: { (object: Any, range: NSRange, stop: UnsafeMutablePointer<ObjCBool>) in
Expand All @@ -86,8 +86,8 @@ public extension NSMutableAttributedString {
let newFont = font.modifyTraits(fontTraits, enable: enable)

self.beginEditing()
self.removeAttribute(NSFontAttributeName, range: range)
self.addAttribute(NSFontAttributeName, value: newFont, range: range)
self.removeAttribute(.font, range: range)
self.addAttribute(.font, value: newFont, range: range)
self.endEditing()
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extension NSAttributedString {

convenience init(
withHTML html: String,
defaultAttributes: [String: Any],
defaultAttributes: [NSAttributedStringKey: Any],
postProcessingHTMLWith htmlTreeProcessor: HTMLTreeProcessor? = nil) {

let htmlParser = HTMLParser()
Expand Down
14 changes: 7 additions & 7 deletions Aztec/Classes/Extensions/NSAttributedString+Lists.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extension NSAttributedString {
var effectiveRange = NSRange()
let targetRange = rangeOfEntireString
guard
let paragraphStyle = attribute(NSParagraphStyleAttributeName, at: location, longestEffectiveRange: &effectiveRange, in: targetRange) as? ParagraphStyle,
let paragraphStyle = attribute(.paragraphStyle, at: location, longestEffectiveRange: &effectiveRange, in: targetRange) as? ParagraphStyle,
let foundList = paragraphStyle.lists.last,
foundList == list
else {
Expand All @@ -32,7 +32,7 @@ extension NSAttributedString {
// so we need to expand the range to grab all the TextList coverage.
while resultRange.location > 0 {
guard
let paragraphStyle = attribute(NSParagraphStyleAttributeName, at: resultRange.location-1, longestEffectiveRange: &effectiveRange, in: targetRange) as? ParagraphStyle,
let paragraphStyle = attribute(.paragraphStyle, at: resultRange.location-1, longestEffectiveRange: &effectiveRange, in: targetRange) as? ParagraphStyle,
let foundList = paragraphStyle.lists.last
else {
break;
Expand All @@ -46,7 +46,7 @@ extension NSAttributedString {
}
while resultRange.endLocation < self.length {
guard
let paragraphStyle = attribute(NSParagraphStyleAttributeName, at: resultRange.endLocation, longestEffectiveRange: &effectiveRange, in: targetRange) as? ParagraphStyle,
let paragraphStyle = attribute(.paragraphStyle, at: resultRange.endLocation, longestEffectiveRange: &effectiveRange, in: targetRange) as? ParagraphStyle,
let foundList = paragraphStyle.lists.last
else {
break;
Expand All @@ -72,7 +72,7 @@ extension NSAttributedString {
///
func itemNumber(in list: TextList, at location: Int) -> Int {
guard
let paragraphStyle = attribute(NSParagraphStyleAttributeName, at: location, effectiveRange: nil) as? ParagraphStyle
let paragraphStyle = attribute(.paragraphStyle, at: location, effectiveRange: nil) as? ParagraphStyle
else {
return NSNotFound
}
Expand All @@ -87,7 +87,7 @@ extension NSAttributedString {
if NSLocationInRange(location, enclosingRange) {
return numberInList
}
if let paragraphStyle = attribute(NSParagraphStyleAttributeName, at: enclosingRange.location, effectiveRange: nil) as? ParagraphStyle,
if let paragraphStyle = attribute(.paragraphStyle, at: enclosingRange.location, effectiveRange: nil) as? ParagraphStyle,
listDepth == paragraphStyle.lists.count {
numberInList += 1
}
Expand All @@ -108,7 +108,7 @@ extension NSAttributedString {
/// - Returns: A TextList optional.
///
func textListAttribute(atIndex index: Int) -> TextList? {
return (attribute(NSParagraphStyleAttributeName, at: index, effectiveRange: nil) as? ParagraphStyle)?.lists.last
return (attribute(.paragraphStyle, at: index, effectiveRange: nil) as? ParagraphStyle)?.lists.last
}

/// Returns the TextList attribute, assuming that there is one, spanning the specified Range.
Expand All @@ -125,7 +125,7 @@ extension NSAttributedString {
//
var list: TextList?

enumerateAttribute(NSParagraphStyleAttributeName, in: range, options: []) { (attribute, range, stop) in
enumerateAttribute(.paragraphStyle, in: range, options: []) { (attribute, range, stop) in
if let paragraphStyle = attribute as? ParagraphStyle {
list = paragraphStyle.lists.last
}
Expand Down
Loading