Good morning!
Pertaining to core data fetch requests, what is the best way to minimize code creation / repetition throughout your swift files?
So far each of my view controllers have their own methods dealing with fetching an Entity. All pretty much identical. Should these be grouped in something such as:
class FetchRequestHelper
{
static func fetchCoreDataEntity( _ context: NSManagedObjectContext ) -> [EnityName]?
{
let request: NSFetchRequest<EnityName> = NSFetchRequest( entityName: "EntityName" )
do
{
let entity = try context.fetch( request )
return entity
}
catch
{
print("Couldn't Fetch Entity")
}
return nil
}
}
About a year in of iOS practice and still trying to learn each day. Feel really slow in the progress so any tips/tricks are greatly appreciated!