Checking and accessing Resource files

What I’m trying to accomplish is writing a function, class, or whatever that accesses the Resource Files where the target media item- specifically a photo- is stored and checks if it exists continuously. This idea is derived from Team Fortress 2’s Coconut JPG mystery.

Please note: I am doing this on an ipad on Swift, using an xcode template

When you say “checks if it exists continuously” I would imagine that you have a triggering mechanism to cause that check to take place.

If you are storing the file in the Applications Documents folder (all iOS Apps have a Document folder) then assuming that you have the name of that file then yes, you can do that. You would have to use Xcode on a Mac and run the code in a Simulator to test.

You could do something like this:

extension FileManager {
    func getDocumentsDirectory() -> URL {
        let paths = urls(for: .documentDirectory, in: .userDomainMask)
        return paths[0]
    }

    func checkFileExists(filename: String) -> Bool {
        let fileUrl = getDocumentsDirectory().appendingPathComponent(filename)
        //  If there is data then you know the file exists
        guard let _ = try? Data(contentsOf: fileUrl) else { return false }
        return true
    }
}

Why check if it exists continuously?