Reputation: 227
I defined an entity Person:
class Person: NSManagedObject {
@NSManaged var firstName: String
@NSManaged var lastName: String
}
Then:
let person = NSEntityDescription.insertNewObjectForEntityForName(entityName, inManagedObjectContext: managedObjectContext!) as! Person
person.firstName = "First name"
person.lastName = "Last name"
Now I'm confused, is person an attribute like firstName and lastName? What is insertNewObjectForEntityForName?
Upvotes: 0
Views: 40
Reputation: 2741
So you defined an entity named: Person ,
Person is a subclass
of type NSManagedObject
. This Person has attributes
firstname & lastname.
if you are asking about the person (lowercase), it is an instance of your class Person (entity).
and insertNewObjectForEntityForName
is the method of NSManagedObject
Class to Insert every new managed Object record in DB. It will create a new records Row in your data table.
Upvotes: 1
Reputation: 9397
A CoreData db can have many types of entities. Person is one such entity. A Person entity has attributes firstName and lastName.
Hope that clears it up.
Upvotes: 0