0
我只是将我的项目斯威夫特3,我得到了一个错误directory.path
行:值类型“字符串”没有成员“stringByAppendingPathComponent”
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()
}
请检查一下,让我知道。
预先感谢您!
看到这个https://stackoverflow.com/questions/35541747/create-directory-in-app-group-container-swift –
你是强制为具有'stringByAppendingPathComponent'的'NSString',因此不要施放它 – Jack