Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not insert new outlet connection error

I have created a custom cell for loading into a table. The interface is complete and now I am trying to link the xib and the class.

I have the split screen view open and I try to control drag the item so that Xcode can make the connection for me. When I fill in the name and click connect I get an error:

Could not insert new outlet connection: Could not insert source code into document at URL://localhost/Users/Velox/Projects/CompanyName/ProjectName/ProjectName/HistoryCell.m because it does not contain a class definition for the class named HistoryCell.

I have set the custom class of the xib to HistoryCell.

What am I missing here?

Thanks.

like image 998
Dale Myers Avatar asked Jun 12 '12 11:06

Dale Myers


3 Answers

This problem seems to be an Xcode bug which creeps up mostly when you replace a file with a new file of the same name. Xcode seems to keep a reference of the older file of the same name.

Anyhow, the way to fix this seems to be -

  1. Clean the project

  2. Click <Your Project> in Project Navigator view. Go to Compile Sources under Build Phases of the target for which you are building. Remove and add back the .m file which is giving you trouble.

  3. Alternatively, in the File Inspector (Utilities view) of the NIB file, under Target Membership, uncheck and check back the target name.

  4. Restart Xcode for good measure.

  5. Of course, deleting and adding back the .m file alone should fix it too.

Steps 1. and 2. alone fixed it for me. Feel free to ask if any step needs expanding.

Cheers and happy coding :)

like image 70
codeburn Avatar answered Nov 12 '22 01:11

codeburn


I fixed this issue by deleting the .m file (reference only) then adding it back in to the project. I think XCode gets corrupted at times (and I'm on the latest 4.6).

like image 23
Daniel Ryan Avatar answered Nov 12 '22 01:11

Daniel Ryan


https://stackoverflow.com/a/16166878/521946

Try to clean your project and restart Xcode.
If it still cannot be connected, follow the Utilities navigation view of Xcode, in the Target membership section, uncheck & check the checkbox, it will be work. Maybe you should rebuild the project after unchecking.

like image 5
Elf Sundae Avatar answered Nov 11 '22 23:11

Elf Sundae