Aviram Netanel
Aviram Netanel

Reputation: 13625

'Class' is ambiguous for type lookup in this context

I did a core-data model:

class Order: NSManagedObject {
    ... //code
}

but when I try to build I get an error:

'Order' is ambiguous for type lookup in this context

Upvotes: 19

Views: 17637

Answers (7)

Magnuti
Magnuti

Reputation: 165

The accepted answer by @aviram-netanel worked for me, but I had a hard time finding the panel lol.

  1. Open your .xcdatamodeld file
  2. Click on one of your entities

enter image description here

  1. Press this button on the top-right of the screen

enter image description here

  1. Select the last tab and fill in this information

enter image description here

Upvotes: 0

Yedy
Yedy

Reputation: 2126

In my case I had an entity named "Client". Client seems to be used internally under the hood somewhere. Changing the entity name to "Company" resolved the issue. So check if your naming is reserverd by the system or other components.
Be sure to change both entity and class name (at least the class name).
enter image description here

Upvotes: 0

theiOSDev
theiOSDev

Reputation: 121

Below are steps that worked for me,

  • Delete "NSManagedObject" files created
  • Clean build
  • Open core data .xcdatamodeld file
  • Open the right pane by selecting "Entity"
  • Set Module to "Current Project", Codegen to "Module None" Setting One Ref Image
  • Now go to Editor Menu from the top and create a subclass "NSManagedObject"
  • Build the project
  • Go back to Enity right pane and change Codegen to "Class Definition" Setting Two Ref Image

Upvotes: 12

Damaris Muhia
Damaris Muhia

Reputation: 1

I had the same issue, on codegen option i had choosen class defination,To fix this: 1.Delete the generated class files 2. Select the Order Entity and on codegen on your right hand side choose manual\none 3. Navigate to Xcode Editor and select "Create NSManagedObject subclass to generate the classes again.

Upvotes: 0

SouthernYankee65
SouthernYankee65

Reputation: 1269

Make sure to clean your build folder also once you make the required changes to your entity settings.

Upvotes: 0

Robin George
Robin George

Reputation: 13

I feel the right solution is to delete the files created by Xcode foe the entity class and attribute class and change the codegen to class definition.

Upvotes: 0

Aviram Netanel
Aviram Netanel

Reputation: 13625

so I figured - the Entity 'Order' should be defined in the core data properties panel.

  1. open core data .xcdatamodeld file

  2. select the Entity 'Order'

  3. On the right select "Current Product Module" under module

  4. select "Category/Extension" under Codegen

enter image description here

Upvotes: 30

Related Questions