@@ -16,7 +16,7 @@ extension Array : _ObjectTypeBridgeable {
1616 } )
1717 }
1818
19- public static func _forceBridgeFromObject( x: NSArray , inout result: Array ? ) {
19+ public static func _forceBridgeFromObject( x: NSArray , result: inout Array ? ) {
2020 var array = [ Element] ( )
2121 for value in x. allObjects {
2222 if let v = value as? Element {
@@ -28,7 +28,7 @@ extension Array : _ObjectTypeBridgeable {
2828 result = array
2929 }
3030
31- public static func _conditionallyBridgeFromObject( x: NSArray , inout result: Array ? ) -> Bool {
31+ public static func _conditionallyBridgeFromObject( x: NSArray , result: inout Array ? ) -> Bool {
3232 _forceBridgeFromObject ( x, result: & result)
3333 return true
3434 }
@@ -74,13 +74,13 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
7474 withUnsafeMutablePointer ( & cnt) { ( ptr: UnsafeMutablePointer < UInt32 > ) -> Void in
7575 aDecoder. decodeValueOfObjCType ( " i " , at: UnsafeMutablePointer < Void > ( ptr) )
7676 }
77- let objects = UnsafeMutablePointer< AnyObject?> . alloc ( Int ( cnt) )
77+ let objects = UnsafeMutablePointer < AnyObject ? > ( allocatingCapacity : Int ( cnt) )
7878 for idx in 0 ..< cnt {
79- objects. advancedBy ( Int ( idx) ) . initialize ( aDecoder. decodeObject ( ) )
79+ objects. advanced ( by : Int ( idx) ) . initialize ( with : aDecoder. decodeObject ( ) )
8080 }
8181 self . init ( objects: UnsafePointer < AnyObject ? > ( objects) , count: Int ( cnt) )
82- objects. destroy ( Int ( cnt) )
83- objects. dealloc ( Int ( cnt) )
82+ objects. deinitialize ( count : Int ( cnt) )
83+ objects. deallocateCapacity ( Int ( cnt) )
8484 } else if aDecoder. dynamicType == NSKeyedUnarchiver . self || aDecoder. containsValueForKey ( " NS.objects " ) {
8585 let objects = aDecoder. _decodeArrayOfObjectsForKey ( " NS.objects " )
8686 self . init ( array: objects)
@@ -160,11 +160,11 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
160160// self.init(objects: ptr.baseAddress, count: array.count)
161161// }
162162 let cnt = array. count
163- let buffer = UnsafeMutablePointer< AnyObject?> . alloc ( cnt)
163+ let buffer = UnsafeMutablePointer < AnyObject ? > ( allocatingCapacity : cnt)
164164 buffer. initializeFrom ( optionalArray)
165165 self . init ( objects: buffer, count: cnt)
166- buffer. destroy ( cnt)
167- buffer. dealloc ( cnt)
166+ buffer. deinitialize ( count : cnt)
167+ buffer. deallocateCapacity ( cnt)
168168 }
169169
170170 public override func isEqual( object: AnyObject ? ) -> Bool {
@@ -199,7 +199,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
199199
200200 public func componentsJoinedByString( separator: String ) -> String {
201201 // make certain to call NSObject's description rather than asking the string interpolator for the swift description
202- return bridge ( ) . map ( ) { ( $0 as! NSObject ) . description } . joinWithSeparator ( separator)
202+ return bridge ( ) . map ( ) { ( $0 as! NSObject ) . description } . joined ( separator : separator)
203203 }
204204
205205 public func containsObject( anObject: AnyObject ) -> Bool {
@@ -233,7 +233,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
233233 /// Alternative pseudo funnel method for fastpath fetches from arrays
234234 /// - Experiment: This is a draft API currently under consideration for official import into Foundation
235235 /// - Note: Since this API is under consideration it may be either removed or revised in the near future
236- public func getObjects( inout objects: [ AnyObject ] , range: NSRange ) {
236+ public func getObjects( objects: inout [ AnyObject ] , range: NSRange ) {
237237 objects. reserveCapacity ( objects. count + range. length)
238238
239239 if self . dynamicType === NSArray . self || self . dynamicType === NSMutableArray . self {
@@ -319,7 +319,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
319319 }
320320 }
321321
322- public struct Generator : GeneratorType {
322+ public struct Iterator : IteratorProtocol {
323323 // TODO: Detect mutations
324324 // TODO: Use IndexingGenerator instead?
325325 let array : NSArray
@@ -342,21 +342,21 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
342342 }
343343 }
344344 public func objectEnumerator( ) -> NSEnumerator {
345- return NSGeneratorEnumerator ( Generator ( self ) )
345+ return NSGeneratorEnumerator ( Iterator ( self ) )
346346 }
347347
348348 public func reverseObjectEnumerator( ) -> NSEnumerator {
349- return NSGeneratorEnumerator ( Generator ( self , reverse: true ) )
349+ return NSGeneratorEnumerator ( Iterator ( self , reverse: true ) )
350350 }
351351
352352 /*@NSCopying*/ public var sortedArrayHint : NSData {
353- let buffer = UnsafeMutablePointer< Int32> . alloc ( count)
353+ let buffer = UnsafeMutablePointer < Int32 > ( allocatingCapacity : count)
354354 for idx in 0 ..< count {
355355 let item = objectAtIndex ( idx) as! NSObject
356356 let hash = item. hash
357- buffer. advancedBy ( idx) . memory = Int32 ( hash) . littleEndian
357+ buffer. advanced ( by : idx) . pointee = Int32 ( hash) . littleEndian
358358 }
359- return NSData ( bytesNoCopy: unsafeBitCast ( buffer, UnsafeMutablePointer< Void> . self ) , length: count * sizeof( Int) , freeWhenDone: true )
359+ return NSData ( bytesNoCopy: unsafeBitCast ( buffer, to : UnsafeMutablePointer< Void> . self ) , length: count * sizeof( Int) , freeWhenDone: true )
360360 }
361361
362362 public func sortedArrayUsingFunction( comparator: @convention ( c) ( AnyObject , AnyObject , UnsafeMutablePointer < Void > ) -> Int , context: UnsafeMutablePointer < Void > ) -> [ AnyObject ] {
@@ -386,7 +386,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
386386 public func objectsAtIndexes( indexes: NSIndexSet ) -> [ AnyObject ] {
387387 var objs = [ AnyObject] ( )
388388 indexes. enumerateRangesUsingBlock { ( range, _) in
389- objs. appendContentsOf ( self . subarrayWithRange ( range) )
389+ objs. append ( contentsOf : self . subarrayWithRange ( range) )
390390 }
391391 return objs
392392 }
@@ -426,7 +426,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
426426 enumerateObjectsAtIndexes ( s, options: opts) { ( obj, idx, stop) -> Void in
427427 if predicate ( obj, idx, stop) {
428428 result = idx
429- stop. memory = true
429+ stop. pointee = true
430430 }
431431 }
432432 return result
@@ -460,7 +460,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
460460 }
461461
462462 let swiftRange = range. toRange ( ) !
463- return allObjects [ swiftRange] . sort { lhs, rhs in
463+ return allObjects [ swiftRange] . sorted { lhs, rhs in
464464 return cmptr ( lhs, rhs) == . OrderedAscending
465465 }
466466 }
@@ -565,7 +565,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
565565}
566566
567567extension NSArray : _CFBridgable , _SwiftBridgable {
568- internal var _cfObject : CFArray { return unsafeBitCast ( self , CFArray . self) }
568+ internal var _cfObject : CFArray { return unsafeBitCast ( self , to : CFArray . self) }
569569 internal var _swiftObject : [ AnyObject ] {
570570 var array : [ AnyObject ] ?
571571 Array . _forceBridgeFromObject ( self , result: & array)
@@ -574,11 +574,11 @@ extension NSArray : _CFBridgable, _SwiftBridgable {
574574}
575575
576576extension NSMutableArray {
577- internal var _cfMutableObject : CFMutableArray { return unsafeBitCast ( self , CFMutableArray . self) }
577+ internal var _cfMutableObject : CFMutableArray { return unsafeBitCast ( self , to : CFMutableArray . self) }
578578}
579579
580580extension CFArray : _NSBridgable , _SwiftBridgable {
581- internal var _nsObject : NSArray { return unsafeBitCast ( self , NSArray . self) }
581+ internal var _nsObject : NSArray { return unsafeBitCast ( self , to : NSArray . self) }
582582 internal var _swiftObject : Array < AnyObject > { return _nsObject. _swiftObject }
583583}
584584
@@ -590,7 +590,7 @@ extension CFArray {
590590 let count = CFArrayGetCount ( self )
591591 result. reserveCapacity ( count)
592592 for i in 0 ..< count {
593- result. append ( unsafeBitCast ( CFArrayGetValueAtIndex ( self , i) , T . self) )
593+ result. append ( unsafeBitCast ( CFArrayGetValueAtIndex ( self , i) , to : T . self) )
594594 }
595595 return result
596596 }
@@ -601,7 +601,7 @@ extension Array : _NSBridgable, _CFBridgable {
601601 internal var _cfObject : CFArray { return _nsObject. _cfObject }
602602}
603603
604- public struct NSBinarySearchingOptions : OptionSetType {
604+ public struct NSBinarySearchingOptions : OptionSet {
605605 public let rawValue : UInt
606606 public init ( rawValue: UInt ) { self . rawValue = rawValue }
607607
@@ -618,7 +618,7 @@ public class NSMutableArray : NSArray {
618618
619619 public func insertObject( anObject: AnyObject , atIndex index: Int ) {
620620 if self . dynamicType === NSMutableArray . self {
621- _storage. insert ( anObject, atIndex : index)
621+ _storage. insert ( anObject, at : index)
622622 } else {
623623 NSRequiresConcreteImplementation ( )
624624 }
@@ -632,7 +632,7 @@ public class NSMutableArray : NSArray {
632632
633633 public func removeObjectAtIndex( index: Int ) {
634634 if self . dynamicType === NSMutableArray . self {
635- _storage. removeAtIndex ( index)
635+ _storage. remove ( at : index)
636636 } else {
637637 NSRequiresConcreteImplementation ( )
638638 }
@@ -642,7 +642,7 @@ public class NSMutableArray : NSArray {
642642 if self . dynamicType === NSMutableArray . self {
643643 let min = index
644644 let max = index + 1
645- _storage. replaceRange ( min..< max, with: [ anObject] )
645+ _storage. replaceSubrange ( min..< max, with: [ anObject] )
646646 } else {
647647 NSRequiresConcreteImplementation ( )
648648 }
@@ -734,7 +734,7 @@ public class NSMutableArray : NSArray {
734734
735735 public func removeObjectsInArray( otherArray: [ AnyObject ] ) {
736736 let set = NSSet ( array : otherArray)
737- for idx in ( 0 ..< count) . reverse ( ) {
737+ for idx in ( 0 ..< count) . reversed ( ) {
738738 if set. containsObject ( objectAtIndex ( idx) ) {
739739 removeObjectAtIndex ( idx)
740740 }
@@ -743,9 +743,9 @@ public class NSMutableArray : NSArray {
743743
744744 public func removeObjectsInRange( range: NSRange ) {
745745 if self . dynamicType === NSMutableArray . self {
746- _storage. removeRange ( range. toRange ( ) !)
746+ _storage. removeSubrange ( range. toRange ( ) !)
747747 } else {
748- for idx in range. toRange ( ) !. reverse ( ) {
748+ for idx in range. toRange ( ) !. reversed ( ) {
749749 removeObjectAtIndex ( idx)
750750 }
751751 }
@@ -763,7 +763,7 @@ public class NSMutableArray : NSArray {
763763 _storage [ idx + range. location] = otherArray [ idx]
764764 }
765765 for idx in range. length..< otherArray. count {
766- _storage. insert ( otherArray [ idx] , atIndex : idx + range. location)
766+ _storage. insert ( otherArray [ idx] , at : idx + range. location)
767767 }
768768 } else {
769769 NSUnimplemented ( )
@@ -823,9 +823,9 @@ public class NSMutableArray : NSArray {
823823 public convenience init ? ( contentsOfURL url: NSURL ) { NSUnimplemented ( ) }
824824}
825825
826- extension NSArray : SequenceType {
827- final public func generate ( ) -> Generator {
828- return Generator ( self )
826+ extension NSArray : Sequence {
827+ final public func makeIterator ( ) -> Iterator {
828+ return Iterator ( self )
829829 }
830830}
831831
0 commit comments