Hello, I was wondering how I can save an entity in the core data programmatically.
I tried the following procedure:
Passing Parameter
MatchCoreData().createEntity(name: "Partidas123")
Func creating entity (I believe it's missing save in the core)
public func createEntity(name: String)
{
// Create the entity
var entities = Array<NSEntityDescription>();
let model = NSManagedObjectModel()
let entity = NSEntityDescription()
if entities.count == 0
{
entity.name = name
entity.managedObjectClassName = String(describing: Match.self)
entities.append(entity)
model.entities = [entity]
saveContext()
}
for item in entities
{
if (item.name?.contains(name))!
{
}else
{
entity.name = name
entity.managedObjectClassName = String(describing: Match.self)
model.entities = [item]
saveContext()
}
}
}