I have been trying to add core data. And every time I got the same error:
error: filename \"EntityName +CoreDataClass.swift\" used twice: \'/Users/userName/
Tom Harrington Answer is correct. However, there is a way to add your own functions and/or vars without doing any of the two mentioned options.
Just create an extension to the class. (make sure you name the swift file something different than the standard auto-generated NSManagesObject files.)
For example. If you have an entity called MyEntity
you could add a swift file called MyEntityExtension.swift
which could look something like this:
import Foundation
import CoreData
import UIKit
extension MyEntity {
var color: UIColor {
get {
return self.colorValue as! UIColor
}
set {
if newValue.isMember(of: UIColor.self) {
self.colorValue = newValue
}
}
}
}