Error Type 'String? 'has no member' default'

Asked 1 months ago, Updated 1 months ago, 2 views

let action=UIAlertController(title: "OK", message: .default) {(_)in

When I write, I get the error Type 'String?' has no member 'default' Why do I get this error?How can I fix the error?


2022-09-30 14:27

1 Answers

Supplement the reason for the error.

The message for the argument is a value of type String?

Therefore, the compiler interprets String as omitted as follows:

UIAlertController (title: "OK", message: String.default)

However, there is no property (member variable) named default in the String type, so
The error String? type does not have the default member variable.

 type 'String?' has no member 'default'

2022-09-30 14:27

If you have any answers or tips

© 2022 OneMinuteCode. All rights reserved.