You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2)
Apple Swift version 4.1-dev (LLVM bdcc78a6ed, Clang 27a368e018, Swift 2e48f09e2e)
Apple Swift version 4.1 (swiftlang-902.0.34 clang-902.0.30)
Additional Detail from JIRA
Votes
0
Component/s
Foundation
Labels
Bug
Assignee
None
Priority
Medium
md5: 5965ddf0411387d0f28422c8af81a84c
duplicates:
SR-6515 Subdata of Data returned from URLSession is equal, but has different hash value
Issue Description:
The second argument in the closure passed to Data's enumerateBytes method is a Data.Index. But, of course, the Data being operated on may be a slice. So does the index parameter represent a zero-based index offset from the beginning of the data, as in Swift 3, or does it start at a non-zero .startIndex as in Swift 4?
As you see, the index is zero-based for a pure-Swift data slice, but is non-zero-based for a Data that began life as a dispatch_data_t from Objective-C. So the upshot is that if you use the index for anything, the result will be like the proverbial box of chocolates.
The text was updated successfully, but these errors were encountered:
Attachment: Download
Environment
Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2)
Apple Swift version 4.1-dev (LLVM bdcc78a6ed, Clang 27a368e018, Swift 2e48f09e2e)
Apple Swift version 4.1 (swiftlang-902.0.34 clang-902.0.30)
Additional Detail from JIRA
md5: 5965ddf0411387d0f28422c8af81a84c
duplicates:
Issue Description:
The second argument in the closure passed to Data's enumerateBytes method is a Data.Index. But, of course, the Data being operated on may be a slice. So does the index parameter represent a zero-based index offset from the beginning of the data, as in Swift 3, or does it start at a non-zero .startIndex as in Swift 4?
The answer is... yes!
When running the project described below:
DataMaker.m:
main.swift:
we get the following output:
As you see, the index is zero-based for a pure-Swift data slice, but is non-zero-based for a Data that began life as a dispatch_data_t from Objective-C. So the upshot is that if you use the index for anything, the result will be like the proverbial box of chocolates.
The text was updated successfully, but these errors were encountered: