Search code examples
arraysswiftxcodesetfoundation

Can't use Set because a Core Data class is also called "Set"


I accidentally named a Core Data class Set. I can't change the class name because the model is already on CloudKit.

But now I can't use the Set struct. Is there anything I can do to use Set structs when I want to? Can I use NSSet instead? Will that impact anything considering I'm using Swift/SwiftUI?

enter image description here


Solution

  • You can specify type of object like this:

    class Set {}
    
    let a = Swift.Set("1") //swift's Set instance
    let b = Set() //your custom Set instance
    let c = YourApp.Set() //your custom Set instance