InvalidSyntax
InvalidSyntax

Reputation: 9495

Changing class of object in XCode

I am trying to give an object in the interface builder a custom class. When typing in the class name in the Identity Inspector it automatically finishes the line as its already present in the dropdown list of available classes. However after entering the class the page comes up with a padlock image and clears the class name.

What is the cause of this and how can I rectify it?

Upvotes: 0

Views: 358

Answers (3)

Rob
Rob

Reputation: 437592

Assuming you've specific the right IB object (e.g., a dynamic cell prototype, whose default class is UITableViewCell) and your custom class is defined correctly (as a subclass of UITableViewCell, itself), then I have a couple of thoughts of what you might try:

  • Sometimes exiting and restarting Xcode is often enough.

  • Also try selecting "Clean" from the "Build" menu (or press shift+command ⌘+K).

  • In the worst case scenario, sometimes you have to exit Xcode and delete the DerivedData folder and then restart Xcode. To find the derived data folder, press command ⌘+, (comma) and go to the last tab, "Locations", and click on the arrow next to the "Derived Data" folder:

    enter image description here

    Having pulled up that folder in Finder, quit Xcode, delete the contents of that DerivedData folder in Finder (after quitting Xcode), and then restart Xcode and try again.

Upvotes: 2

InvalidSyntax
InvalidSyntax

Reputation: 9495

I think I have found the solution (not sure if I have found a fix for the actual problem or just found a way around it)...

I changed the Lock dropdown setting to Nothing and it now allows me to set my own custom class to the Object in the file. Whats strange is that the document lock was previously set to Inherit (Nothing) anyway so not sure what the difference is here.

enter image description here

Upvotes: 0

crz
crz

Reputation: 458

firstly, you must reload xcode

if it not work you must have subclass associate with it in IB

Create CustomClass:UITableViewCell then drop UITableViewCell to IB and then just type the name If dropdown list not display, reload Xcode

Upvotes: 3

Related Questions