Y Y
Y Y

Reputation: 25

CoreData NSManagedObject Swift subclass with reserved keyword

I have a CoreData model that is already in use. In that data model, one of the relationships uses a reserved keyword in Swift, "case" in this case. When I use XCode to create subclass of the NSManagedObject, it gets an error because it tries to declare a @NSManaged var case, and "case" is a reserved keyword.

If I try to change the relationship name in the CoreData model, the app will not be able to read the previous database without migration. Is there a way to get around this naming issue without doing a database migration or am I stuck with database migration?

Upvotes: 0

Views: 184

Answers (1)

Robert Masen
Robert Masen

Reputation: 139

Back ticks will escape reserved words in swift 2. Not sure if that got trashed in swift 3.

var `case`

edit: this is still available in Swift 3.0

Upvotes: 1

Related Questions