Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 5
    No. String(describing:) should never be used for anything else than debugging. It is not the normal String initializer. Commented Mar 31, 2018 at 9:33
  • Hello @Moritz so what can i do for remove optional word ? i have a Int value and than i want to print in label Commented Mar 31, 2018 at 9:54
  • Just use the normal String() initializer. But don't give it an optional, unwrap first. Or, like in your example, use ??. Like this: let str = String(x ?? 0) Commented Mar 31, 2018 at 10:07
  • developer.apple.com/documentation/swift/string/2427941-init i understand your point what is the use of describing Commented Mar 31, 2018 at 11:03
  • It's mostly for debugging purposes. You can describe the name of classes, get the description of instances, etc. But it should never be used for strings that are used in the app itself. Commented Mar 31, 2018 at 11:05