@@ -39,14 +39,14 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
39
39
internal var _storage = [ AnyObject] ( )
40
40
41
41
public var count : Int {
42
- guard self . dynamicType === NSArray . self || self . dynamicType === NSMutableArray . self else {
42
+ guard type ( of : self ) === NSArray . self || type ( of : self ) === NSMutableArray . self else {
43
43
NSRequiresConcreteImplementation ( )
44
44
}
45
45
return _storage. count
46
46
}
47
47
48
48
public func object( at index: Int ) -> AnyObject {
49
- guard self . dynamicType === NSArray . self || self . dynamicType === NSMutableArray . self else {
49
+ guard type ( of : self ) === NSArray . self || type ( of : self ) === NSMutableArray . self else {
50
50
NSRequiresConcreteImplementation ( )
51
51
}
52
52
return _storage [ index]
@@ -79,7 +79,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
79
79
self . init ( objects: UnsafePointer < AnyObject ? > ( objects) , count: Int ( cnt) )
80
80
objects. deinitialize ( count: Int ( cnt) )
81
81
objects. deallocate ( capacity: Int ( cnt) )
82
- } else if aDecoder. dynamicType == NSKeyedUnarchiver . self || aDecoder. containsValue ( forKey: " NS.objects " ) {
82
+ } else if type ( of : aDecoder) == NSKeyedUnarchiver . self || aDecoder. containsValue ( forKey: " NS.objects " ) {
83
83
let objects = aDecoder. _decodeArrayOfObjectsForKey ( " NS.objects " )
84
84
self . init ( array: objects)
85
85
} else {
@@ -114,10 +114,10 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
114
114
}
115
115
116
116
public func copy( with zone: NSZone ? = nil ) -> AnyObject {
117
- if self . dynamicType === NSArray . self {
117
+ if type ( of : self ) === NSArray . self {
118
118
// return self for immutable type
119
119
return self
120
- } else if self . dynamicType === NSMutableArray . self {
120
+ } else if type ( of : self ) === NSMutableArray . self {
121
121
let array = NSArray ( )
122
122
array. _storage = self . _storage
123
123
return array
@@ -130,7 +130,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
130
130
}
131
131
132
132
public func mutableCopy( with zone: NSZone ? = nil ) -> AnyObject {
133
- if self . dynamicType === NSArray . self || self . dynamicType === NSMutableArray . self {
133
+ if type ( of : self ) === NSArray . self || type ( of : self ) === NSMutableArray . self {
134
134
// always create and return an NSMutableArray
135
135
let mutableArray = NSMutableArray ( )
136
136
mutableArray. _storage = self . _storage
@@ -178,7 +178,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
178
178
}
179
179
180
180
internal var allObjects : [ AnyObject ] {
181
- if self . dynamicType === NSArray . self || self . dynamicType === NSMutableArray . self {
181
+ if type ( of : self ) === NSArray . self || type ( of : self ) === NSMutableArray . self {
182
182
return _storage
183
183
} else {
184
184
return ( 0 ..< count) . map { idx in
@@ -261,7 +261,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
261
261
internal func getObjects( _ objects: inout [ AnyObject ] , range: NSRange ) {
262
262
objects. reserveCapacity ( objects. count + range. length)
263
263
264
- if self . dynamicType === NSArray . self || self . dynamicType === NSMutableArray . self {
264
+ if type ( of : self ) === NSArray . self || type ( of : self ) === NSMutableArray . self {
265
265
objects += _storage [ range. toRange ( ) !]
266
266
return
267
267
}
@@ -646,7 +646,7 @@ public class NSMutableArray : NSArray {
646
646
}
647
647
648
648
public func insert( _ anObject: AnyObject , at index: Int ) {
649
- guard self . dynamicType === NSMutableArray . self else {
649
+ guard type ( of : self ) === NSMutableArray . self else {
650
650
NSRequiresConcreteImplementation ( )
651
651
}
652
652
_storage. insert ( anObject, at: index)
@@ -659,14 +659,14 @@ public class NSMutableArray : NSArray {
659
659
}
660
660
661
661
public func removeObject( at index: Int ) {
662
- guard self . dynamicType === NSMutableArray . self else {
662
+ guard type ( of : self ) === NSMutableArray . self else {
663
663
NSRequiresConcreteImplementation ( )
664
664
}
665
665
_storage. remove ( at: index)
666
666
}
667
667
668
668
public func replaceObject( at index: Int , with anObject: AnyObject ) {
669
- guard self . dynamicType === NSMutableArray . self else {
669
+ guard type ( of : self ) === NSMutableArray . self else {
670
670
NSRequiresConcreteImplementation ( )
671
671
}
672
672
let min = index
@@ -681,7 +681,7 @@ public class NSMutableArray : NSArray {
681
681
public init ( capacity numItems: Int ) {
682
682
super. init ( objects: [ ] , count: 0 )
683
683
684
- if self . dynamicType === NSMutableArray . self {
684
+ if type ( of : self ) === NSMutableArray . self {
685
685
_storage. reserveCapacity ( numItems)
686
686
}
687
687
}
@@ -703,7 +703,7 @@ public class NSMutableArray : NSArray {
703
703
}
704
704
705
705
public func addObjectsFromArray( _ otherArray: [ AnyObject ] ) {
706
- if self . dynamicType === NSMutableArray . self {
706
+ if type ( of : self ) === NSMutableArray . self {
707
707
_storage += otherArray
708
708
} else {
709
709
for obj in otherArray {
@@ -713,15 +713,15 @@ public class NSMutableArray : NSArray {
713
713
}
714
714
715
715
public func exchangeObject( at idx1: Int , withObjectAt idx2: Int ) {
716
- if self . dynamicType === NSMutableArray . self {
716
+ if type ( of : self ) === NSMutableArray . self {
717
717
swap ( & _storage[ idx1] , & _storage[ idx2] )
718
718
} else {
719
719
NSUnimplemented ( )
720
720
}
721
721
}
722
722
723
723
public func removeAllObjects( ) {
724
- if self . dynamicType === NSMutableArray . self {
724
+ if type ( of : self ) === NSMutableArray . self {
725
725
_storage. removeAll ( )
726
726
} else {
727
727
while count > 0 {
@@ -768,7 +768,7 @@ public class NSMutableArray : NSArray {
768
768
}
769
769
770
770
public func removeObjects( in range: NSRange ) {
771
- if self . dynamicType === NSMutableArray . self {
771
+ if type ( of : self ) === NSMutableArray . self {
772
772
_storage. removeSubrange ( range. toRange ( ) !)
773
773
} else {
774
774
for idx in range. toRange ( ) !. reversed ( ) {
@@ -783,7 +783,7 @@ public class NSMutableArray : NSArray {
783
783
}
784
784
785
785
public func replaceObjectsInRange( _ range: NSRange , withObjectsFromArray otherArray: [ AnyObject ] ) {
786
- if self . dynamicType === NSMutableArray . self {
786
+ if type ( of : self ) === NSMutableArray . self {
787
787
_storage. reserveCapacity ( count - range. length + otherArray. count)
788
788
for idx in 0 ..< range. length {
789
789
_storage [ idx + range. location] = otherArray [ idx]
@@ -797,7 +797,7 @@ public class NSMutableArray : NSArray {
797
797
}
798
798
799
799
public func setArray( _ otherArray: [ AnyObject ] ) {
800
- if self . dynamicType === NSMutableArray . self {
800
+ if type ( of : self ) === NSMutableArray . self {
801
801
_storage = otherArray
802
802
} else {
803
803
replaceObjectsInRange ( NSMakeRange ( 0 , count) , withObjectsFromArray: otherArray)
@@ -807,7 +807,7 @@ public class NSMutableArray : NSArray {
807
807
public func insertObjects( _ objects: [ AnyObject ] , atIndexes indexes: IndexSet ) {
808
808
precondition ( objects. count == indexes. count)
809
809
810
- if self . dynamicType === NSMutableArray . self {
810
+ if type ( of : self ) === NSMutableArray . self {
811
811
_storage. reserveCapacity ( count + indexes. count)
812
812
}
813
813
0 commit comments