2

At some point I deleted the Object to my appdelegate file for some reason from the XIB. I added a new object, and selected MyAppNameDelegate as the class. However, it's not connected to file owner, and I dont seem to get the option when right clicking and dragging. I think this is causing me some runtime issues. Any ideas?

agmcleod
  • 12,451
  • 11
  • 52
  • 92

3 Answers3

5

If you are referring to your MainMenu, the the file's owner is an object of type NSApplication.

In IB, you should select your file's owner, access it's 'delegate' outlet and drag it (as to draw a line) to your app delegate. This will restore the connection.

Check also that your file's owner has got the NSApplication class type. Maybe it got changed somehow.

sergio
  • 67,961
  • 11
  • 98
  • 119
  • My application is called SimpleContacts, making a pretty cut and dry contact management app for practice. The Object in the XIB i deleted is called "Simple Contacts App Delegate". I added that back and connected it to the SimpleContactsAppDelegate.h no problem. However, it is also not delegated to the File's Owner in the xib. I can see in a new app i built earlier that those two are connected by default. – agmcleod May 29 '11 at 21:05
  • Thanks for the suggestion, but that's the odd thing. The option isn't even there. I wonder if I'm missing some sort of setting. I pushed my latest changes up on github: https://github.com/agmcleod/SimpleContacts/tree/parttwo/SimpleContacts – agmcleod May 29 '11 at 21:13
  • Looked at the file owner of another app. It was UIApplication, while this one was NSObject. I updated it and connected it as a delegate. Thanks for helping me get there! – agmcleod May 29 '11 at 21:14
  • Unfortunately, I am working off my iPad and cannot access IB, but added one more suggestion... Sorry if it is of no help. I cannot explain otherwise this behavior and can't check further into your project for now... – sergio May 29 '11 at 21:18
4

I had this same problem. I found a lot of half-answers on different threads, so I decided to put them together here.

  1. Drag an NSObject instance from the Objects palette to the area below "Objects" where the objects for your xib are listed (click on the triangle at the lower left if you can't see it) for MainWindow.xib. The object should show up as a solid orange box.
  2. Select this newly-created NSObject, and change its class to the name of your new App Delegate (whatever the file name is without the .h or .m), using the Identity Inspector. This should be an option in the pop-out list.
  3. Control-drag from the File's Owner to the new object, which should not be displayed as " App Delegate", and select delegate.
  4. You will also probably have to reconnect the Window (and possible other views) to your new delegate. Do this by dragging from the App Delegate to the Window and selecting window.

Hope this helps.

borticus
  • 156
  • 5
  • Just wasted about 10 hours of my life getting an icon to show in the status bar on OS X 10.10. A thousand upboats from here. – qff Apr 25 '15 at 23:03
1

This was driving me nuts also.

I marked +1 above, the answer does in fact help, the answer is cryptic, so this will help explain in finer detail how to get a delegate or another connection that won't link directly into the file using the "Assistant Editor" view.

right click = control key + left click.!

IN XCode 4. Select any of your XIB files. Say for a UIScrollView you added, you want to set the Delegate for it. Well unlike the prior IB where you just open up connections inspector, and drag a connection to the file. Its actually just the same here. BUT a difference.

(NOTE:The dock is panel 2 from the left. Only with a XIB open) Open up the Dock > http://developer.apple.com/LIBRARY/IOS/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/InterfaceBuilder/InterfaceBuilder.html

There is a small triangle arrow there at the bottom of the Dock.

At the very top of the Dock is "Files Owner", without the dock opened, it is the white box with orange trim.

Select the view or what ever needs delegate access to the File (UISegmentControl drove me nuts on this too), right click and drag a connection on "New Referencing outlet" to the Docks "Files Owner", and a list will pop up.

Like wise, you can right click on the "Files Owner" and remove connections easily there, or make new ones. Dock Opened and Connecting the Delegate for UIScrollView