I'm finishing IOS Swift Tutorial "FoodTracker", but there's a error that I can find solution and I dont understand what is wrong and how to fixit:
The error:
Value of tuple type '()' has no member 'path'
This error is shown for variable "Meal.ArchiveUrl.path" at below code.
My code, at MealtableViewController (that its equal to IOS tutorial):
private func saveMeals(){
let isSuccessfulSave = NSKeyedArchiver.archiveRootObject(meals, toFile: Meal.ArchiveUrl.path )
if isSuccessfulSave {
os_log("Meals successfully saved.", log: OSLog.default, type: .debug)
} else {
os_log("Failed to save meals...", log: OSLog.default, type: .error)
}
}
And at Meal.swift, there's the declaration:
/MARK: Archiving Paths
static let DocumentsDirectory = FileManager().urls(for: .documentDirectory, in: .userDomainMask).first!
static let ArchiveUrl = DocumentsDirectory.appendingPathComponent("meals")
Somebody could help me with this, please?
Code is right, and there should not be any error. Try to set type explicitly on ArchiveUrl like:
static let ArchiveUrl: URL = DocumentsDirectory.appendingPathComponent("meals")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With