apple / swift-corelibs-foundation

The Foundation Project, providing core utilities, internationalization, and OS independence
swift.org
Apache License 2.0
5.26k stars 1.13k forks source link

[SR-10502] Change `NSString.data(using:allowLossyConversion:)` parameter types to match ObjC #3440

Open compnerd opened 5 years ago

compnerd commented 5 years ago
Previous ID SR-10502
Radar None
Original Reporter @compnerd
Type Improvement
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Foundation | |Labels | Improvement | |Assignee | None | |Priority | Medium | md5: 328542ae228bb8d4f36f48748abac01a

Issue Description:

NSString has the following method signature in ObjectiveC:
{{- (NSData *)dataUsingEncoding:(NSStringEncoding)encoding allowLossyConversion:(BOOL)lossy;}}

while it has the following signature in Swift:

func data(using encoding: UInt, allowLossyConversion lossy: Bool) -> Data?

We should change it to be:

func data(using encoding: String.Encoding, allowsLossyConversion lossy: Bool) -> Data?

compnerd commented 5 years ago

CC: @millenomi

millenomi commented 5 years ago

The docs have UInt too; whatever happened there, thanks for the feedback on this.