Core data 将对象类型声明为NSManagedObject或类名

Core data 将对象类型声明为NSManagedObject或类名,core-data,nsmanagedobject,Core Data,Nsmanagedobject,在核心数据中,如果我有个人实体,以下两者之间是否存在任何差异: NSManagedObject *aPerson = [NSEntityDescription insertNewObjectForEntityForName:@"Person" inManagedObjectContext:[self managedObjectContext]]; 或 人应该是Person类型还是NSManagedObject类型?有区别吗?您应该将其声明为aPerson类。这样编译器就知道了确切的类类型 Pe

在核心数据中,如果我有个人实体,以下两者之间是否存在任何差异:

NSManagedObject *aPerson = [NSEntityDescription insertNewObjectForEntityForName:@"Person" inManagedObjectContext:[self managedObjectContext]];


人应该是Person类型还是NSManagedObject类型?有区别吗?

您应该将其声明为aPerson类。这样编译器就知道了确切的类类型

Person *aPerson = [NSEntityDescription insertNewObjectForEntityForName:@"Person" inManagedObjectContext:[self managedObjectContext]];