Skip to content

Commit b5db69f

Browse files
committed
Add a fix-it for bytes/mutableBytes, to help migrate from NSData to
struct Data. <rdar://problem/26246299> Missing fixit for Data.bytes
1 parent 7aaa565 commit b5db69f

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

stdlib/public/SDK/Foundation/Data.swift

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -266,20 +266,11 @@ public struct Data : ReferenceConvertible, CustomStringConvertible, Equatable, H
266266
}
267267
}
268268

269-
@available(*, unavailable, renamed: "count")
270-
public var length : Int {
271-
get {
272-
fatalError()
273-
}
274-
set {
275-
fatalError()
276-
}
277-
}
278269

279270
private func _getUnsafeBytesPointer() -> UnsafePointer<Void> {
280271
return _mapUnmanaged { return $0.bytes }
281272
}
282-
273+
283274
/// Access the bytes in the data.
284275
///
285276
/// - warning: The byte pointer argument should not be stored and used outside of the lifetime of the call to the closure.
@@ -638,6 +629,21 @@ public struct Data : ReferenceConvertible, CustomStringConvertible, Equatable, H
638629
public func makeIterator() -> Data.Iterator {
639630
return IndexingIterator(_elements: self)
640631
}
632+
633+
// MARK: -
634+
//
635+
636+
@available(*, unavailable, renamed: "count")
637+
public var length : Int {
638+
get { fatalError() }
639+
set { fatalError() }
640+
}
641+
642+
@available(*, unavailable, message: "use withUnsafeBytes instead")
643+
public var bytes: UnsafePointer<Void> { fatalError() }
644+
645+
@available(*, unavailable, message: "use withUnsafeMutableBytes instead")
646+
public var mutableBytes: UnsafeMutablePointer<Void> { fatalError() }
641647
}
642648

643649
/// Returns `true` if the two `Data` arguments are equal.

0 commit comments

Comments
 (0)