stdlib/NSString APIs on String: fix two bugs and add more tests

stringWithBytes(_:length:encoding:) was passing an array to Objective-C
incorrectly, and a garbage NSString was being constructed as a result.

Unhide the initializer was accidentally hidden.


Swift SVN r18674
This commit is contained in:
Dmitri Hrybenko
2014-05-30 20:30:57 +00:00
parent 085c126266
commit df71a47fe4
2 changed files with 45 additions and 18 deletions

View File

@@ -724,7 +724,7 @@ extension String {
encoding: NSStringEncoding
) -> String? {
return NSString(
bytes: &bytes, length: min(bytes.count, length), encoding: encoding
bytes: bytes, length: min(bytes.count, length), encoding: encoding
) as NSString? // HACK: FIXME: coerce to optional NSString to handle nil
}
@@ -818,8 +818,8 @@ extension String {
/// Returns a `String` object initialized by using a given
/// format string as a template into which the remaining argument
/// values are substituted.
init(format: String, _ _arguments: CVarArg...) {
self = String(format: format, arguments: _arguments)
init(format: String, _ arguments: CVarArg...) {
self = String(format: format, arguments: arguments)
}
// - (instancetype)