Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.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?

like image 313
Reiss Zurbyk Avatar asked Mar 08 '23 22:03

Reiss Zurbyk


1 Answers

XCUIKeyboardKey is now an enum. Try this:

let deleteString = stringValue.characters.map { _ in XCUIKeyboardKey.delete.rawValue }.joined(separator: "")
like image 134
Bruno Rocha Avatar answered Mar 30 '23 19:03

Bruno Rocha