// Writes `data` to a file named `file`. func writeData(_ data: Data, to file: String) { let documentDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let fileURL = documentDirectoryURL.appendingPathComponent(file) try? data.write(to: fileURL) } // Removes file named `file`. func remove(file: String) { let documentDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let fileURL = documentDirectoryURL.appendingPathComponent(file) try? FileManager.default.removeItem(at: fileURL) } // Reads `Data` from a file named `file`. If the file doesn't exists returns `nil`. func readData(from file: String) -> Data? { let documentDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let fileURL = documentDirectoryURL.appendingPathComponent(file) return try? Data(contentsOf: fileURL) } final class DiskCache<T>: CacheProtocol { func setValue(_ value: T?, forKey key: String) { } func getValue(forKey key: String) -> T? { } func fetchValue(forKey key: String, completion: @escaping (T?) -> Void) { } }
iOS
How do the processes of inserting data at the beginning and end of a buffer's memory area differ?
Describe your experience mentoring and supporting colleagues professionally.
Is it possible to directly instantiate a protocol object in a programming language?
Which protocols are typically implemented in Swift to ensure standard contracts and object behavior?
What methods can be used to implement screen transitions in iOS applications?
Explain what Behavior-Driven Development (BDD) methodology is and how it is applied in software development.
How can DispatchGroup be used to sequentially execute requests with the ability to cancel on the third without waiting for the fourth?
What processes and stages are initiated when launching a software application?
What rule determines the accessibility of an Open Class, whether it is public or private?
What methods can you use to improve the performance of interface rendering on the screen?
In what order do constructors and initializers execute when creating an instance of a class?
How many times is the loadView method called in the lifecycle of UIViewController?
Which has a greater importance: highPriorityGesture or simultaneousGesture?
Should data type be considered when choosing what to cache?
How do you imagine the most suitable professional environment and working conditions for yourself?
Can you explain what URL means and what its main function on the internet is?
What are the advantages and disadvantages of using the objectWillChange.send method in data model update architecture?
Tell me about one of your achievements or projects that you are particularly proud of
What is the role of the SceneDelegate class in the application lifecycle?