Reiss Zurbyk
Reiss Zurbyk

Reputation: 113

.joined(separator:) in Swift 4/Xcode 9?

I am writing UITests and recently updated to Xcode 9.

This line of code throws an error:

let deleteString = stringValue.characters.map { _ in XCUIKeyboardKeyDelete }.joined(separator: "")

The error on this line is with .joined(separator:) and says:

Type of expression is ambiguous without more context

It's inside a function meant to clear the text out of a UITextField during a UITest.

This code was working before I upgraded to Xcode 9. Any way to convert the syntax for Swift 4 / Xcode 9?

Upvotes: 4

Views: 723

Answers (1)

Bruno Rocha
Bruno Rocha

Reputation: 998

XCUIKeyboardKey is now an enum. Try this:

let deleteString = stringValue.characters.map { _ in XCUIKeyboardKey.delete.rawValue }.joined(separator: "")

Upvotes: 7

Related Questions