Some examples (just going down the readme):
> The observer pattern lets one object observe changes on another object. Apple added language-level support for this pattern in Swift 5.1 with the addition of Publisher in the Combine framework.
- Apple did not add language-level support, the Combine framework is a framework
- NSNotification center was added in iOS 2.0
extension ViewController: ImagePickerDelegate {
func didSelect(image: UIImage?) {
self.yourImageView.image = image
self.dismiss(animated: true, completion: nil)
}
}
> Good To GO- No you're not: what about error handling, permissions, etc.
- There are dozens of libraries for this on Github that do the above and more, why not use them?
func getDocumentDirectoryPath() -> URL {
guard let url = useFileHandler.urls(for: .documentDirectory,
in: .userDomainMask).first else { fatalError("Can't find path") }
return url
}
func createFile(resourceName: String, fileExtension: String) {
let fileURLProject = Bundle.main.path(forResource: resourceName, ofType: fileExtension)
let folderUrl = getDocumentDirectoryPath()
let fileUrl = folderUrl.appendingPathComponent("\(resourceName).\(fileExtension)")
do {
try useFileHandler.copyItem(atPath: fileURLProject ?? "", toPath: fileUrl.path)
} catch {
print(error)
}
}
- You shouldn't fatalError in code intended to be reusable and ready to blindly "copy and paste"- print(error) doesn't exactly inspire confidence
- Again, plenty of libraries exist for this (and Foundation's FileManager isn't that verbose anyway)
struct User: Codable {
var first_name: String
var last_name: String
var country: String
}
- You should use CodingKeys or JSONDecoder.KeyDecodingStrategy instead of snake_case- This section would benefit from a concrete example of JSON<->Codable<->JSON
...and so on. I hope I don't come off too critical here, I just think the author would be better off building something more akin to an Awesome list of links to blog posts, as opposed to a single source of truth of surface-level information where where the bar of knowledge is much higher.