Skip to content

Commit 1654a3e

Browse files
committedMay 24, 2016
Drop NS from AttributedString (but leave NSMutableAttributedString for future renaming back for struct variants)
1 parent 2c957da commit 1654a3e

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed
 

‎Foundation/NSAttributedString.swift

+23-18
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import CoreFoundation
1111

12-
public class NSAttributedString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
12+
public class AttributedString: NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
1313

1414
private let _cfinfo = _CFInfo(typeID: CFAttributedStringGetTypeID())
1515
private let _string: NSString
@@ -95,12 +95,12 @@ public class NSAttributedString : NSObject, NSCopying, NSMutableCopying, NSSecur
9595
}
9696
}
9797

98-
public func attributedSubstringFromRange(_ range: NSRange) -> NSAttributedString { NSUnimplemented() }
98+
public func attributedSubstringFromRange(_ range: NSRange) -> AttributedString { NSUnimplemented() }
9999

100100
public func attributesAtIndex(_ location: Int, longestEffectiveRange range: NSRangePointer, inRange rangeLimit: NSRange) -> [String : AnyObject] { NSUnimplemented() }
101101
public func attribute(_ attrName: String, atIndex location: Int, longestEffectiveRange range: NSRangePointer, inRange rangeLimit: NSRange) -> AnyObject? { NSUnimplemented() }
102102

103-
public func isEqualToAttributedString(_ other: NSAttributedString) -> Bool { NSUnimplemented() }
103+
public func isEqualToAttributedString(_ other: AttributedString) -> Bool { NSUnimplemented() }
104104

105105
public init(string str: String) {
106106
_string = str._nsObject
@@ -118,7 +118,7 @@ public class NSAttributedString : NSObject, NSCopying, NSMutableCopying, NSSecur
118118
addAttributesToAttributeArray(attrs: attrs)
119119
}
120120

121-
public init(attributedString attrStr: NSAttributedString) { NSUnimplemented() }
121+
public init(attributedString attrStr: AttributedString) { NSUnimplemented() }
122122

123123
private func addAttributesToAttributeArray(attrs: [String : AnyObject]?) {
124124
guard _string.length > 0 else {
@@ -134,24 +134,29 @@ public class NSAttributedString : NSObject, NSCopying, NSMutableCopying, NSSecur
134134
}
135135
}
136136

137-
public func enumerateAttributesInRange(_ enumerationRange: NSRange, options opts: NSAttributedStringEnumerationOptions, usingBlock block: ([String : AnyObject], NSRange, UnsafeMutablePointer<ObjCBool>) -> Void) { NSUnimplemented() }
138-
public func enumerateAttribute(_ attrName: String, inRange enumerationRange: NSRange, options opts: NSAttributedStringEnumerationOptions, usingBlock block: (AnyObject?, NSRange, UnsafeMutablePointer<ObjCBool>) -> Void) { NSUnimplemented() }
137+
public func enumerateAttributesInRange(_ enumerationRange: NSRange, options opts: EnumerationOptions, usingBlock block: ([String : AnyObject], NSRange, UnsafeMutablePointer<ObjCBool>) -> Void) { NSUnimplemented() }
138+
public func enumerateAttribute(_ attrName: String, inRange enumerationRange: NSRange, options opts: EnumerationOptions, usingBlock block: (AnyObject?, NSRange, UnsafeMutablePointer<ObjCBool>) -> Void) { NSUnimplemented() }
139139
}
140140

141-
extension NSAttributedString: _CFBridgable {
141+
extension AttributedString: _CFBridgable {
142142
internal var _cfObject: CFAttributedString { return unsafeBitCast(self, to: CFAttributedString.self) }
143143
}
144144

145-
public struct NSAttributedStringEnumerationOptions : OptionSet {
146-
public let rawValue : UInt
147-
public init(rawValue: UInt) { self.rawValue = rawValue }
148-
public static let Reverse = NSAttributedStringEnumerationOptions(rawValue: 1 << 1)
149-
public static let LongestEffectiveRangeNotRequired = NSAttributedStringEnumerationOptions(rawValue: 1 << 20)
150-
}
145+
extension AttributedString {
151146

147+
public struct EnumerationOptions: OptionSet {
148+
public let rawValue: UInt
149+
public init(rawValue: UInt) {
150+
self.rawValue = rawValue
151+
}
152+
public static let Reverse = EnumerationOptions(rawValue: 1 << 1)
153+
public static let LongestEffectiveRangeNotRequired = EnumerationOptions(rawValue: 1 << 20)
154+
}
155+
156+
}
152157

153158

154-
public class NSMutableAttributedString : NSAttributedString {
159+
public class NSMutableAttributedString : AttributedString {
155160

156161
public func replaceCharactersInRange(_ range: NSRange, withString str: String) { NSUnimplemented() }
157162
public func setAttributes(_ attrs: [String : AnyObject]?, range: NSRange) { NSUnimplemented() }
@@ -163,11 +168,11 @@ public class NSMutableAttributedString : NSAttributedString {
163168
public func addAttributes(_ attrs: [String : AnyObject], range: NSRange) { NSUnimplemented() }
164169
public func removeAttribute(_ name: String, range: NSRange) { NSUnimplemented() }
165170

166-
public func replaceCharactersInRange(_ range: NSRange, withAttributedString attrString: NSAttributedString) { NSUnimplemented() }
167-
public func insertAttributedString(_ attrString: NSAttributedString, atIndex loc: Int) { NSUnimplemented() }
168-
public func appendAttributedString(_ attrString: NSAttributedString) { NSUnimplemented() }
171+
public func replaceCharactersInRange(_ range: NSRange, withAttributedString attrString: AttributedString) { NSUnimplemented() }
172+
public func insertAttributedString(_ attrString: AttributedString, atIndex loc: Int) { NSUnimplemented() }
173+
public func appendAttributedString(_ attrString: AttributedString) { NSUnimplemented() }
169174
public func deleteCharactersInRange(_ range: NSRange) { NSUnimplemented() }
170-
public func setAttributedString(_ attrString: NSAttributedString) { NSUnimplemented() }
175+
public func setAttributedString(_ attrString: AttributedString) { NSUnimplemented() }
171176

172177
public func beginEditing() { NSUnimplemented() }
173178
public func endEditing() { NSUnimplemented() }

‎Foundation/NSPersonNameComponentsFormatter.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class PersonNameComponentsFormatter : Formatter {
6565
/* Returns attributed string with annotations for each component. For each range, attributes can be obtained by querying
6666
dictionary key NSPersonNameComponentKey , using NSPersonNameComponent constant values.
6767
*/
68-
public func annotatedStringFromPersonNameComponents(_ components: NSPersonNameComponents) -> NSAttributedString { NSUnimplemented() }
68+
public func annotatedStringFromPersonNameComponents(_ components: NSPersonNameComponents) -> AttributedString { NSUnimplemented() }
6969

7070
/* NSPersonNameComponentsFormatter currently only implements formatting, not parsing. Until it implements parsing, this will always return NO.
7171
*/

‎TestFoundation/TestNSAttributedString.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TestNSAttributedString : XCTestCase {
3030

3131
func test_initWithString() {
3232
let string = "Lorem 😀 ipsum dolor sit amet, consectetur adipiscing elit. ⌘ Phasellus consectetur et sem vitae consectetur. Nam venenatis lectus a laoreet blandit. ಠ_ರೃ"
33-
let attrString = NSAttributedString(string: string)
33+
let attrString = AttributedString(string: string)
3434
XCTAssertEqual(attrString.string, string)
3535
XCTAssertEqual(attrString.length, string.utf16Count)
3636

@@ -50,7 +50,7 @@ class TestNSAttributedString : XCTestCase {
5050
let string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus consectetur et sem vitae consectetur. Nam venenatis lectus a laoreet blandit."
5151
let attributes: [String : AnyObject] = ["attribute.placeholder.key" : "attribute.placeholder.value" as NSString]
5252

53-
let attrString = NSAttributedString(string: string, attributes: attributes)
53+
let attrString = AttributedString(string: string, attributes: attributes)
5454
XCTAssertEqual(attrString.string, string)
5555
XCTAssertEqual(attrString.length, string.utf16Count)
5656

0 commit comments

Comments
 (0)
Please sign in to comment.