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