Lumialxk
Lumialxk

Reputation: 6369

Weird class name conflict in Swift3 with Core Data

I'm working with Core Data. Here is the class(generated by editor).

public class Tag: NSManagedObject {

}

And I defined an enum whose case has the same name as above.

enum NoteListType {
    case Tag
    case Album
}

When I tried to build it, I got this error message.

Use of undeclared type 'Tag'

When I CMD-click Tag to jump to its definition, it shows two options. Please help me. Many thanks in advance.

Update:
I tried to rename enum cases but still got undeclared type. Maybe it's caused by Xcode 8.2.1 and Core Data. And I have published my project on Github. Here is the link.

Upvotes: 1

Views: 654

Answers (2)

Pallavi Srikhakollu
Pallavi Srikhakollu

Reputation: 598

I downloaded your git project and found out that this conflict is arising because of Target Membership of each file has both entity and Target so OS was unable to detect which class is referenced. I checked out the membership from Entity (kept only target) and the Tag ,Album were detected. Although I was unable to run the code as i got some compile team errors as you were trying to directly type cast NSManagedObject at some places . Please refer below screenshot . enter image description here

I hope this helps you out.

Upvotes: 6

bsm-2000
bsm-2000

Reputation: 265

Try this ..

enum NoteListType {
    case tag
    case album
}

Upvotes: 1

Related Questions