我第一次尝试编写一些 SwiftUI 代码,并在尝试制作简单的表格视图时遇到问题。在此代码中teams
是一个 数组String
,但它List
给了我以下错误:
初始化程序“init(_:rowContent:)”要求“String”符合“Identifying”
var body: some View {
let teams = getTeams()
Text("Hello there")
List(teams) { team in
}
}
Run Code Online (Sandbox Code Playgroud)
有人知道这意味着什么吗?
我正在尝试实现深层链接来导航到应用程序上的帖子,这是一个较旧的项目,所以我必须添加该类SceneDelegate
。仅当应用程序处于活动状态或在后台时,深层链接实现才有效。如果应用程序尚未加载,深层链接将不起作用。我看过很多关于此的帖子和教程,但没有找到原因,有人遇到过类似的问题吗?
在类中AppDelegate
,我添加了实现来处理以下函数的链接:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {}
Run Code Online (Sandbox Code Playgroud)
在SceneDelegate
我实现处理以下函数中的链接:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {}
func …
Run Code Online (Sandbox Code Playgroud) 如何快速初始化一个空对象?这就是我所拥有的,但它也需要参数
var userInfo:User = User()
init(email: String, isVerified: String, profileImageURL: String, reputation: String, twitterHandle: String, userName: String) {
self._email = email
self._isVerified = isVerified
self._profileImageURL = profileImageURL
self._reputation = reputation
self._twitterHandle = twitterHandle
self._userName = userName
}
Run Code Online (Sandbox Code Playgroud)