相关疑难解决方法(0)

SwiftUI中Text(“”)和Text(verbatim:“”)初始化程序之间的区别

我一直在关注Apple的SwiftUI教程。在此过程中,我经常将Text对象与以下初始化程序一起使用:

/// Creates an instance that displays `content` verbatim.
public init<S>(_ content: S) where S : StringProtocol
Run Code Online (Sandbox Code Playgroud)

Now, in the fifth tutorial of the series, I've encountered the following usage of Text:

Text(verbatim: "")
Run Code Online (Sandbox Code Playgroud)

The description in the interface is the same as for the other initializer:

Text(verbatim: "")
Run Code Online (Sandbox Code Playgroud)

Question

What's the two initializers for and how are they different / when would I use which?

swift swiftui

7
推荐指数
2
解决办法
770
查看次数

标签 统计

swift ×1

swiftui ×1