@@ -39,14 +39,14 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
3939 internal var _storage = [ AnyObject] ( )
4040
4141 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 {
4343 NSRequiresConcreteImplementation ( )
4444 }
4545 return _storage. count
4646 }
4747
4848 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 {
5050 NSRequiresConcreteImplementation ( )
5151 }
5252 return _storage [ index]
@@ -79,7 +79,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
7979 self . init ( objects: UnsafePointer < AnyObject ? > ( objects) , count: Int ( cnt) )
8080 objects. deinitialize ( count: Int ( cnt) )
8181 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 " ) {
8383 let objects = aDecoder. _decodeArrayOfObjectsForKey ( " NS.objects " )
8484 self . init ( array: objects)
8585 } else {
@@ -114,10 +114,10 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
114114 }
115115
116116 public func copy( with zone: NSZone ? = nil ) -> AnyObject {
117- if self . dynamicType === NSArray . self {
117+ if type ( of : self ) === NSArray . self {
118118 // return self for immutable type
119119 return self
120- } else if self . dynamicType === NSMutableArray . self {
120+ } else if type ( of : self ) === NSMutableArray . self {
121121 let array = NSArray ( )
122122 array. _storage = self . _storage
123123 return array
@@ -130,7 +130,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
130130 }
131131
132132 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 {
134134 // always create and return an NSMutableArray
135135 let mutableArray = NSMutableArray ( )
136136 mutableArray. _storage = self . _storage
@@ -178,7 +178,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
178178 }
179179
180180 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 {
182182 return _storage
183183 } else {
184184 return ( 0 ..< count) . map { idx in
@@ -261,7 +261,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
261261 internal func getObjects( _ objects: inout [ AnyObject ] , range: NSRange ) {
262262 objects. reserveCapacity ( objects. count + range. length)
263263
264- if self . dynamicType === NSArray . self || self . dynamicType === NSMutableArray . self {
264+ if type ( of : self ) === NSArray . self || type ( of : self ) === NSMutableArray . self {
265265 objects += _storage [ range. toRange ( ) !]
266266 return
267267 }
@@ -646,7 +646,7 @@ public class NSMutableArray : NSArray {
646646 }
647647
648648 public func insert( _ anObject: AnyObject , at index: Int ) {
649- guard self . dynamicType === NSMutableArray . self else {
649+ guard type ( of : self ) === NSMutableArray . self else {
650650 NSRequiresConcreteImplementation ( )
651651 }
652652 _storage. insert ( anObject, at: index)
@@ -659,14 +659,14 @@ public class NSMutableArray : NSArray {
659659 }
660660
661661 public func removeObject( at index: Int ) {
662- guard self . dynamicType === NSMutableArray . self else {
662+ guard type ( of : self ) === NSMutableArray . self else {
663663 NSRequiresConcreteImplementation ( )
664664 }
665665 _storage. remove ( at: index)
666666 }
667667
668668 public func replaceObject( at index: Int , with anObject: AnyObject ) {
669- guard self . dynamicType === NSMutableArray . self else {
669+ guard type ( of : self ) === NSMutableArray . self else {
670670 NSRequiresConcreteImplementation ( )
671671 }
672672 let min = index
@@ -681,7 +681,7 @@ public class NSMutableArray : NSArray {
681681 public init ( capacity numItems: Int ) {
682682 super. init ( objects: [ ] , count: 0 )
683683
684- if self . dynamicType === NSMutableArray . self {
684+ if type ( of : self ) === NSMutableArray . self {
685685 _storage. reserveCapacity ( numItems)
686686 }
687687 }
@@ -703,7 +703,7 @@ public class NSMutableArray : NSArray {
703703 }
704704
705705 public func addObjectsFromArray( _ otherArray: [ AnyObject ] ) {
706- if self . dynamicType === NSMutableArray . self {
706+ if type ( of : self ) === NSMutableArray . self {
707707 _storage += otherArray
708708 } else {
709709 for obj in otherArray {
@@ -713,15 +713,15 @@ public class NSMutableArray : NSArray {
713713 }
714714
715715 public func exchangeObject( at idx1: Int , withObjectAt idx2: Int ) {
716- if self . dynamicType === NSMutableArray . self {
716+ if type ( of : self ) === NSMutableArray . self {
717717 swap ( & _storage[ idx1] , & _storage[ idx2] )
718718 } else {
719719 NSUnimplemented ( )
720720 }
721721 }
722722
723723 public func removeAllObjects( ) {
724- if self . dynamicType === NSMutableArray . self {
724+ if type ( of : self ) === NSMutableArray . self {
725725 _storage. removeAll ( )
726726 } else {
727727 while count > 0 {
@@ -768,7 +768,7 @@ public class NSMutableArray : NSArray {
768768 }
769769
770770 public func removeObjects( in range: NSRange ) {
771- if self . dynamicType === NSMutableArray . self {
771+ if type ( of : self ) === NSMutableArray . self {
772772 _storage. removeSubrange ( range. toRange ( ) !)
773773 } else {
774774 for idx in range. toRange ( ) !. reversed ( ) {
@@ -783,7 +783,7 @@ public class NSMutableArray : NSArray {
783783 }
784784
785785 public func replaceObjectsInRange( _ range: NSRange , withObjectsFromArray otherArray: [ AnyObject ] ) {
786- if self . dynamicType === NSMutableArray . self {
786+ if type ( of : self ) === NSMutableArray . self {
787787 _storage. reserveCapacity ( count - range. length + otherArray. count)
788788 for idx in 0 ..< range. length {
789789 _storage [ idx + range. location] = otherArray [ idx]
@@ -797,7 +797,7 @@ public class NSMutableArray : NSArray {
797797 }
798798
799799 public func setArray( _ otherArray: [ AnyObject ] ) {
800- if self . dynamicType === NSMutableArray . self {
800+ if type ( of : self ) === NSMutableArray . self {
801801 _storage = otherArray
802802 } else {
803803 replaceObjectsInRange ( NSMakeRange ( 0 , count) , withObjectsFromArray: otherArray)
@@ -807,7 +807,7 @@ public class NSMutableArray : NSArray {
807807 public func insertObjects( _ objects: [ AnyObject ] , atIndexes indexes: IndexSet ) {
808808 precondition ( objects. count == indexes. count)
809809
810- if self . dynamicType === NSMutableArray . self {
810+ if type ( of : self ) === NSMutableArray . self {
811811 _storage. reserveCapacity ( count + indexes. count)
812812 }
813813
0 commit comments