Xcode is aware of changes made by IB and if you change something in IB then go back to xcode you are prompted to save the changed nib(s) along with the source code files.
XCode is aware of changes made by IB because the IB generates the actual objects, not a code template from which those objects get generated later. The resulting nib file
is the binary data that is used at run time.
The consideration when bouncing between XCode and IB is how to add IBOutlets and IBActions. If you're starting from scratch and are clear on how you're going to design your class, you can easily add the outlets and actions in IB, then use IB to generate your class files, and finish the implementation in XCode. However, if you've already generated your class from IB, or are adding outlets and actions to a class whose header has already been added to a nib, or are writing an app that's anything more than a third-party tutorial, you've got a choice to make.
Two options:
- Hand code the new IBOutlets and IBActions, then prompt IB to re-read the file headers; all the new outlets and actions will now be visible in IB. To do this, I go to the Classes tab of my nib file, right-click the file in question and choose "Read
name_of_file.h."
- Use IB to add the new IBOutlets and IBActions and re-generate the source files. Upon selecting the save location for these files, you'll be prompted to overwrite or merge the code. Of course, if you've been busily writing code in XCode, you do not want to overwrite.
Personally I prefer to poke IB with a stick and re-read my file headers. It's clean and simple, and completely non-destructive.
Best,
Anton