@@ -16,7 +16,7 @@ extension Array : _ObjectTypeBridgeable {
16
16
} )
17
17
}
18
18
19
- public static func _forceBridgeFromObject( x: NSArray , inout result: Array ? ) {
19
+ public static func _forceBridgeFromObject( x: NSArray , result: inout Array ? ) {
20
20
var array = [ Element] ( )
21
21
for value in x. allObjects {
22
22
if let v = value as? Element {
@@ -28,7 +28,7 @@ extension Array : _ObjectTypeBridgeable {
28
28
result = array
29
29
}
30
30
31
- public static func _conditionallyBridgeFromObject( x: NSArray , inout result: Array ? ) -> Bool {
31
+ public static func _conditionallyBridgeFromObject( x: NSArray , result: inout Array ? ) -> Bool {
32
32
_forceBridgeFromObject ( x, result: & result)
33
33
return true
34
34
}
@@ -74,13 +74,13 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
74
74
withUnsafeMutablePointer ( & cnt) { ( ptr: UnsafeMutablePointer < UInt32 > ) -> Void in
75
75
aDecoder. decodeValueOfObjCType ( " i " , at: UnsafeMutablePointer < Void > ( ptr) )
76
76
}
77
- let objects = UnsafeMutablePointer< AnyObject?> . alloc ( Int ( cnt) )
77
+ let objects = UnsafeMutablePointer < AnyObject ? > ( allocatingCapacity : Int ( cnt) )
78
78
for idx in 0 ..< cnt {
79
- objects. advancedBy ( Int ( idx) ) . initialize ( aDecoder. decodeObject ( ) )
79
+ objects. advanced ( by : Int ( idx) ) . initialize ( with : aDecoder. decodeObject ( ) )
80
80
}
81
81
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) )
84
84
} else if aDecoder. dynamicType == NSKeyedUnarchiver . self || aDecoder. containsValueForKey ( " NS.objects " ) {
85
85
let objects = aDecoder. _decodeArrayOfObjectsForKey ( " NS.objects " )
86
86
self . init ( array: objects)
@@ -160,11 +160,11 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
160
160
// self.init(objects: ptr.baseAddress, count: array.count)
161
161
// }
162
162
let cnt = array. count
163
- let buffer = UnsafeMutablePointer< AnyObject?> . alloc ( cnt)
163
+ let buffer = UnsafeMutablePointer < AnyObject ? > ( allocatingCapacity : cnt)
164
164
buffer. initializeFrom ( optionalArray)
165
165
self . init ( objects: buffer, count: cnt)
166
- buffer. destroy ( cnt)
167
- buffer. dealloc ( cnt)
166
+ buffer. deinitialize ( count : cnt)
167
+ buffer. deallocateCapacity ( cnt)
168
168
}
169
169
170
170
public override func isEqual( object: AnyObject ? ) -> Bool {
@@ -199,7 +199,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
199
199
200
200
public func componentsJoinedByString( separator: String ) -> String {
201
201
// 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)
203
203
}
204
204
205
205
public func containsObject( anObject: AnyObject ) -> Bool {
@@ -233,7 +233,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
233
233
/// Alternative pseudo funnel method for fastpath fetches from arrays
234
234
/// - Experiment: This is a draft API currently under consideration for official import into Foundation
235
235
/// - 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 ) {
237
237
objects. reserveCapacity ( objects. count + range. length)
238
238
239
239
if self . dynamicType === NSArray . self || self . dynamicType === NSMutableArray . self {
@@ -319,7 +319,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
319
319
}
320
320
}
321
321
322
- public struct Generator : GeneratorType {
322
+ public struct Iterator : IteratorProtocol {
323
323
// TODO: Detect mutations
324
324
// TODO: Use IndexingGenerator instead?
325
325
let array : NSArray
@@ -342,21 +342,21 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
342
342
}
343
343
}
344
344
public func objectEnumerator( ) -> NSEnumerator {
345
- return NSGeneratorEnumerator ( Generator ( self ) )
345
+ return NSGeneratorEnumerator ( Iterator ( self ) )
346
346
}
347
347
348
348
public func reverseObjectEnumerator( ) -> NSEnumerator {
349
- return NSGeneratorEnumerator ( Generator ( self , reverse: true ) )
349
+ return NSGeneratorEnumerator ( Iterator ( self , reverse: true ) )
350
350
}
351
351
352
352
/*@NSCopying*/ public var sortedArrayHint : NSData {
353
- let buffer = UnsafeMutablePointer< Int32> . alloc ( count)
353
+ let buffer = UnsafeMutablePointer < Int32 > ( allocatingCapacity : count)
354
354
for idx in 0 ..< count {
355
355
let item = objectAtIndex ( idx) as! NSObject
356
356
let hash = item. hash
357
- buffer. advancedBy ( idx) . memory = Int32 ( hash) . littleEndian
357
+ buffer. advanced ( by : idx) . pointee = Int32 ( hash) . littleEndian
358
358
}
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 )
360
360
}
361
361
362
362
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
386
386
public func objectsAtIndexes( indexes: NSIndexSet ) -> [ AnyObject ] {
387
387
var objs = [ AnyObject] ( )
388
388
indexes. enumerateRangesUsingBlock { ( range, _) in
389
- objs. appendContentsOf ( self . subarrayWithRange ( range) )
389
+ objs. append ( contentsOf : self . subarrayWithRange ( range) )
390
390
}
391
391
return objs
392
392
}
@@ -426,7 +426,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
426
426
enumerateObjectsAtIndexes ( s, options: opts) { ( obj, idx, stop) -> Void in
427
427
if predicate ( obj, idx, stop) {
428
428
result = idx
429
- stop. memory = true
429
+ stop. pointee = true
430
430
}
431
431
}
432
432
return result
@@ -460,7 +460,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
460
460
}
461
461
462
462
let swiftRange = range. toRange ( ) !
463
- return allObjects [ swiftRange] . sort { lhs, rhs in
463
+ return allObjects [ swiftRange] . sorted { lhs, rhs in
464
464
return cmptr ( lhs, rhs) == . OrderedAscending
465
465
}
466
466
}
@@ -565,7 +565,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
565
565
}
566
566
567
567
extension NSArray : _CFBridgable , _SwiftBridgable {
568
- internal var _cfObject : CFArray { return unsafeBitCast ( self , CFArray . self) }
568
+ internal var _cfObject : CFArray { return unsafeBitCast ( self , to : CFArray . self) }
569
569
internal var _swiftObject : [ AnyObject ] {
570
570
var array : [ AnyObject ] ?
571
571
Array . _forceBridgeFromObject ( self , result: & array)
@@ -574,11 +574,11 @@ extension NSArray : _CFBridgable, _SwiftBridgable {
574
574
}
575
575
576
576
extension NSMutableArray {
577
- internal var _cfMutableObject : CFMutableArray { return unsafeBitCast ( self , CFMutableArray . self) }
577
+ internal var _cfMutableObject : CFMutableArray { return unsafeBitCast ( self , to : CFMutableArray . self) }
578
578
}
579
579
580
580
extension CFArray : _NSBridgable , _SwiftBridgable {
581
- internal var _nsObject : NSArray { return unsafeBitCast ( self , NSArray . self) }
581
+ internal var _nsObject : NSArray { return unsafeBitCast ( self , to : NSArray . self) }
582
582
internal var _swiftObject : Array < AnyObject > { return _nsObject. _swiftObject }
583
583
}
584
584
@@ -590,7 +590,7 @@ extension CFArray {
590
590
let count = CFArrayGetCount ( self )
591
591
result. reserveCapacity ( count)
592
592
for i in 0 ..< count {
593
- result. append ( unsafeBitCast ( CFArrayGetValueAtIndex ( self , i) , T . self) )
593
+ result. append ( unsafeBitCast ( CFArrayGetValueAtIndex ( self , i) , to : T . self) )
594
594
}
595
595
return result
596
596
}
@@ -601,7 +601,7 @@ extension Array : _NSBridgable, _CFBridgable {
601
601
internal var _cfObject : CFArray { return _nsObject. _cfObject }
602
602
}
603
603
604
- public struct NSBinarySearchingOptions : OptionSetType {
604
+ public struct NSBinarySearchingOptions : OptionSet {
605
605
public let rawValue : UInt
606
606
public init ( rawValue: UInt ) { self . rawValue = rawValue }
607
607
@@ -618,7 +618,7 @@ public class NSMutableArray : NSArray {
618
618
619
619
public func insertObject( anObject: AnyObject , atIndex index: Int ) {
620
620
if self . dynamicType === NSMutableArray . self {
621
- _storage. insert ( anObject, atIndex : index)
621
+ _storage. insert ( anObject, at : index)
622
622
} else {
623
623
NSRequiresConcreteImplementation ( )
624
624
}
@@ -632,7 +632,7 @@ public class NSMutableArray : NSArray {
632
632
633
633
public func removeObjectAtIndex( index: Int ) {
634
634
if self . dynamicType === NSMutableArray . self {
635
- _storage. removeAtIndex ( index)
635
+ _storage. remove ( at : index)
636
636
} else {
637
637
NSRequiresConcreteImplementation ( )
638
638
}
@@ -642,7 +642,7 @@ public class NSMutableArray : NSArray {
642
642
if self . dynamicType === NSMutableArray . self {
643
643
let min = index
644
644
let max = index + 1
645
- _storage. replaceRange ( min..< max, with: [ anObject] )
645
+ _storage. replaceSubrange ( min..< max, with: [ anObject] )
646
646
} else {
647
647
NSRequiresConcreteImplementation ( )
648
648
}
@@ -734,7 +734,7 @@ public class NSMutableArray : NSArray {
734
734
735
735
public func removeObjectsInArray( otherArray: [ AnyObject ] ) {
736
736
let set = NSSet ( array : otherArray)
737
- for idx in ( 0 ..< count) . reverse ( ) {
737
+ for idx in ( 0 ..< count) . reversed ( ) {
738
738
if set. containsObject ( objectAtIndex ( idx) ) {
739
739
removeObjectAtIndex ( idx)
740
740
}
@@ -743,9 +743,9 @@ public class NSMutableArray : NSArray {
743
743
744
744
public func removeObjectsInRange( range: NSRange ) {
745
745
if self . dynamicType === NSMutableArray . self {
746
- _storage. removeRange ( range. toRange ( ) !)
746
+ _storage. removeSubrange ( range. toRange ( ) !)
747
747
} else {
748
- for idx in range. toRange ( ) !. reverse ( ) {
748
+ for idx in range. toRange ( ) !. reversed ( ) {
749
749
removeObjectAtIndex ( idx)
750
750
}
751
751
}
@@ -763,7 +763,7 @@ public class NSMutableArray : NSArray {
763
763
_storage [ idx + range. location] = otherArray [ idx]
764
764
}
765
765
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)
767
767
}
768
768
} else {
769
769
NSUnimplemented ( )
@@ -823,9 +823,9 @@ public class NSMutableArray : NSArray {
823
823
public convenience init ? ( contentsOfURL url: NSURL ) { NSUnimplemented ( ) }
824
824
}
825
825
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 )
829
829
}
830
830
}
831
831
0 commit comments