How to set my Primary Key?

0

I'm developing an application in Swift and started using Core Data recently. I need to define which attribute of my entity will be my primary key . For example:

I have an entity that has the attributes of the class:

  • id
  • name
  • age

I need the "id" attribute to be my primary key .

It can be in Objective-C itself, I just need to know how I define it.

    
asked by anonymous 07.11.2014 / 11:34

1 answer

1

// Swift

  class Foo: RLMObject {
        dynamic var id = 0

        override class func primaryKey() -> String {
            return "id"
        }
    }

// Core data

[ link

    
07.11.2014 / 11:50