Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS FoodTracker Tutorial: Value of tuple type '()' has no member 'path'

Tags:

ios

swift

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?

like image 992
Smaily Carrilho Avatar asked Dec 03 '25 20:12

Smaily Carrilho


1 Answers

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")
like image 73
Максуд Даудов Avatar answered Dec 05 '25 10:12

Максуд Даудов



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!