gpt4 book ai didi

ios - 类型 'String' 的值没有成员 'stringByAppendingPathComponent'

转载 作者:行者123 更新时间:2023-11-30 12:16:46 25 4
gpt4 key购买 nike

我刚刚将项目转换为 Swift 3,但出现错误 directory.path行:

Error: Value of type 'String' has no member 'stringByAppendingPathComponent'.

我已经尝试过let realmPath = (directory as NSString).stringByAppendingPathComponent相反,我收到以下错误:

Cannot convert value of type 'URL' to type 'NSString' in coercion.

override func awake(withContext context: Any?) {
super.awake(withContext: context)

let directory: URL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.RazvanJulian.app")!
let realmPath = directory.path.stringByAppendingPathComponent("db.realm") /* ERROR */

RLMRealm.setDefaultRealmPath(realmPath)
realmToken = RLMRealm.default().addNotificationBlock { note, realm in
self.reloadTableData()
}
reloadTableData()
}

请检查并告诉我。

提前谢谢您!

最佳答案

stringByAppendingPathComponent 在 Swift 3 中变成了 appendingPathComponent。试试这个:

directory.appendingPathComponent("component")

关于ios - 类型 'String' 的值没有成员 'stringByAppendingPathComponent',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45342523/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com