Friday, 1 June 2012

iOS - Remove a connection

The advantages of XCode is it offers the Interface Builder to create connections between the interface (view) and the Object-C file (Controller). Those connections are created by selecting the elements in the interface builder and clicking the Object-C file (normally .h file) while holding the left button of the mouse.

This actions modifies all three files:
- The Interface Building file (*.storyboard) by adding the connection
- The .h file, by adding an IBOutlet or an IBAction
- The .m file, by adding a "@synthesize" or by adding an empty method.

Sometimes the connections could be badly named or related with wrong element (IBOutlet instead of IBAction, for example). Thus, to remove it, you could do the follow:

Interface Building(*.storyboard)
1. Select the item
2. Open the "Connections Inspector"
3. Click on the upper left side of the destination of the connection to be removed.

Header file (*.h)
1. Remove the line related with the connection (IBOutlet or IBAction)

Implementation file (*.m)
If it is an IBOutlet
1. Remove the "@synthesize" line
2. In the viewDidUnload, remove the follow line

[self setIBOUTLETNAME:nil];

If it is an IBAction
1. Remove the empty method created.

No comments:

Post a Comment