Aug 22, 2017 · 1 min read
Core data is more “Swift”y as it uses generics to get fully typed return types. You have covered important tasks with core data but the core snippets do can use core data utility functions for e.g.
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Photo")could be rewritten as
let fetchRequest : NSFetchRequest<Photo> = Photo.fetchRequest()And this code here
if let photoEntity = NSEntityDescription.insertNewObject(forEntityName: "Photo", into: context) as? Photo {
photoEntity.author = dictionary["author"] as? String
photoEntity.tags = dictionary["tags"] as? Stringcan be rewritten as
let photo = Photo(context : context)
photo.author = dictionary["author"] as? String
photo.tags = dictionary["tags"] as? String