Search code examples
objective-cxcodecocoaibactioniboutlet

Xcode 4 control-drag won't create first IBOutlet or IBAction if '@end' is a header file's last line


I created an Xcode 4.5.2 project starting with the Single View Application for iPhone template. After adding a UIButton to MainStoryboard.storyboard, I'm able to control-drag from the button to ViewController.h's code to create a new IBOutlet or IBAction. with extra line

However, if I remove the last line following @end, which is empty, control-dragging does not offer to create an IBOutlet or IBAction. without extra line

If I add a property to ViewController, then control-dragging offers to create IBOutlets and IBActions again. existing property

Edit 1: As jhilgert00 pointed out, adding curly braces, as if to create a place to declare instance variables, causes Xcode to once again offer to create IBOutlets and IBActions.

Is this an Xcode bug? Or should I not trim the empty line after @end?

Edit 2: This issue has been fixed in Xcode 5.


Solution

  • My answer would be that this is a bug that should be filed at https://bugreport.apple.com, I doubt anyone here can give a useful answer. That said it's always a good idea to leave whitespace at the end of a file!