I\'m getting the error
\'stringByAppendingPathComponent\' is unavailable: Use \'stringByAppendingPathComponent\' on NSString instead.
when
You can create a URL rather rather than a String path.
let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first
let fileURL = documentsURL?.appendingPathComponent("test.sqlite")
If you absolutely need the path, then you can get it like this:
guard let path = fileURL?.path else {
return
}
print(path) // path will exist at this point
There was some discussion in the thread you mentioned that Apple may be purposely guiding people toward using URLs rather than String paths.
See also:
You can use:
let dbPath = (documentsFolder as NSString).stringByAppendingPathComponent("db.sqlite")