@@ -12,7 +12,7 @@ import CoreFoundation
12
12
public class NSAttributedString : NSObject , NSCopying , NSMutableCopying , NSSecureCoding {
13
13
14
14
private let _cfinfo = _CFInfo ( typeID: CFAttributedStringGetTypeID ( ) )
15
- private let _string : String
15
+ private let _string : NSString
16
16
private let _attributeArray : CFRunArrayRef
17
17
18
18
public required init ? ( coder aDecoder: NSCoder ) {
@@ -44,14 +44,14 @@ public class NSAttributedString : NSObject, NSCopying, NSMutableCopying, NSSecur
44
44
}
45
45
46
46
public var string : String {
47
- return _string
47
+ return _string. _swiftObject
48
48
}
49
49
50
50
public func attributesAtIndex( _ location: Int , effectiveRange range: NSRangePointer ) -> [ String : AnyObject ] {
51
- var cfRange = CFRange ( location : NSNotFound , length : 0 )
51
+ var cfRange = CFRange ( )
52
52
return withUnsafeMutablePointer ( & cfRange) { ( rangePointer: UnsafeMutablePointer < CFRange > ) -> [ String : AnyObject ] in
53
53
// Get attributes value from `_attributeArray`
54
- let value = CFRunArrayGetValueAtIndex ( _attributeArray , location, rangePointer, nil ) . takeUnretainedValue ( )
54
+ let value = CFAttributedStringGetAttributes ( _cfObject , location, rangePointer)
55
55
56
56
// Convert the value to [String : AnyObject]
57
57
let dictionary = unsafeBitCast ( value, to: NSDictionary . self)
@@ -73,7 +73,7 @@ public class NSAttributedString : NSObject, NSCopying, NSMutableCopying, NSSecur
73
73
}
74
74
75
75
public var length : Int {
76
- return _string . length
76
+ return CFAttributedStringGetLength ( _cfObject )
77
77
}
78
78
79
79
public func attribute( _ attrName: String , atIndex location: Int , effectiveRange range: NSRangePointer ) -> AnyObject ? { NSUnimplemented ( ) }
@@ -85,15 +85,15 @@ public class NSAttributedString : NSObject, NSCopying, NSMutableCopying, NSSecur
85
85
public func isEqualToAttributedString( _ other: NSAttributedString ) -> Bool { NSUnimplemented ( ) }
86
86
87
87
public init ( string str: String ) {
88
- _string = str
88
+ _string = str. _nsObject
89
89
_attributeArray = CFRunArrayCreate ( kCFAllocatorDefault)
90
90
91
91
super. init ( )
92
92
addAttributesToAttributeArray ( attrs: nil )
93
93
}
94
94
95
95
public init ( string str: String , attributes attrs: [ String : AnyObject ] ? ) {
96
- _string = str
96
+ _string = str. _nsObject
97
97
_attributeArray = CFRunArrayCreate ( kCFAllocatorDefault)
98
98
99
99
super. init ( )
0 commit comments