Connecting File's Owner to View Issue - xcode

I'm having an issue connecting the view and IBActions/Outlets to File's Owner in Xcode 4.2's nib. When I create a new nib file, I'm going to File -> New File -> Select UI on the right -> Select "View" -> Device Family of iPhone -> then save it as TestView.xib. The new nib appears, but when I try to control + drag from File's Owner to View or anything else, nothing at all happens, the line just disappears without letting me select it as an outlet. The same issue occurs when I try to connect IBActions, Pickers, Labels or really anything to File's Owner. I cannot connect anything to it.
I'm working through a programming book that provided source codes, and when I play around with the nibs in there, everything is already connected to File's Owner. I can reconnect everything just fine in those files as well. I've been having to type up the program and then drag and drop the source codes nibs rather than being able to do it myself.
I'm sure that there is something little that I'm missing, and I've been doing research on it and trying to figure it out for days to no avail. Any help would be much appreciated, thank you!

My guess is that you have not set the class for File's Owner correctly. Select File's Owner in the vertical bar on the left of the Interface Builder view, and in the Utilities (right) bar, go to the third tab (Identity inspector) and set Class to be your view controller's class.

Related

manual option is not showing in Xcode 11 assistant editor and how to add IBOutlet?

I recently updated to Xcode 11 and some of its user interface changed. in older version of Xcode there was options of accessing files in assistant editor using automatic or manual. but in this version of Xcode I can't see any manual option in assistant editor. so I am not able to add IBOutlet and IBAction methods to particular storyboard.
so can anyone tell me how to add these actions and outlets, that would be great help. thanks
By pressing the above button, Xcode will split the view and allow you to select a custom file using the file tree at the top.
You are correct.
The Manual option is no longer visible. You can still achieve the same result by doing a quick open using Cmd+Shift+O then type the name of any file you want to open. Press the Alt key and the file will open in the Assistant Editor Window.
As others have noted the new add editor button allows you to add new editors and open files into them. You could file a bug report but you may want to consider that you're likely to get a "works as designed" type of reply.
You can always change or add new keyboard shortcuts to get the behavior you want by viewing the preferences key bindings area and search for the command you want to shortcut.
Note
You can still ctrl+drag from storyboard to the class by the Adjust
Editor button in the upper right of the storyboard. Then just select
Assistant Editor on the list. After which you can make IBOutlets/IBActions.
open your storyboard, hold option key and select the file you want
In the documentation outline of storyboard, try to choose the "correct" item, which you want to set up outlet connections. Say you want to set up an outlet connection for cell of table/collection view.
View Controller > Collection View > Cell > Content View > Image View.
Try to select Cell, "Content View" or "Image View", then check the jump bar of assistant editor, you're probably able to switch to the .swift file you want.
Reference

Xcode Interface Builder - "correct" way to delete/rename miswired IBOutlets / IBActions?

I am new to Xcode, working through Swift, so I'm not sure if what I am decribing is actually a bug.
When using interface builder and the assistant editor, I can create lables, buttons etc, and create Outlets and Action in the code with a control-drag.
So long as I am perfect, no problem. But I seem to run into problems if, for example, I make a mispelling of the object name. Or, I choose outlet instead of action. I can't seem to find a way to make a correction that does't seem to totally screw up the IDE. Even if I delete the object in the IB and the code, it seems to leave problems behind when I build. Or, if I try to delete the line in code and re-drag it, a new line of code is created, but the object seems to now reference the new name, and the old, now missing name.
Again, I am working with Swift --- Since I don't use/know Objective-C I don't know if there is a similar behavior using that language.
Appreciate any pointers. (Other than don't use the Interface builder / storyboards / Swift.)
Use the Connections inspector to break the connection. Then you can modify/delete the object and/or the code without having to worry.
The accepted answer is fine, but there are a few ways to do the same thing.
Method One
Right click the view in the storyboard and then click the little x by the referencing outlet.
Method Two
Right click the view name in the Document Outline. Then click the little x by the referencing outlet.
Method Three
Select the view on the storyboard and then click the Connections Inspector. Then you can click the little x to remove an outlet reference.
Extra References in Code
If you are getting outlet connections in code that you didn't add yourself see this answer.
You can find unused IBOutlets in the file in which they're declared by looking in the "gutter" of the source editor for an "unfilled hole".

File's Owner is not responding?

I'm creating app, using IB. But File's Owner doesn't want to work! I can't see, what in it, can't drag line to code from buttons in IB.
In code, all's okay. Connection with First Responder is wokrs nice, but it isn't that i want.
For example, now i can't connect UIButton with it's IBOutlet, cauze, when I drag line to code from button, there are nothing happens.
What's the problem?
Thx,
Maxim.
Set the file's owner's class in IB:
Select the file's owner (by clicking on it)
In the utilities area open the "Identity Inspector".
Set the topmost field "Custom Class" to your file's owner's class.

Xcode keyboard shortcuts for go to class from xib and from xib to class?

Is there a keyboard shortcut for jumping from the current xib file to it's class (ViewController)? And back from it's class to it's xib file again?
I use ctrl-command-up/down all the time to to jump between header and source, be great to have one for the view xib also.
There are a couple of quick ways to get to the XIB associated with a class.
CTRL-5-↓-enter
This will open the jump bar to the current file. Assuming your XIB is named the same as your class -- which is usually good practice to do -- the matching XIB will be the next item in the list if you are in your implementation file, or two down if you are in your header file.
Alternately, you can open the XIB or StoryBoard associated with the file with one mouse-click if you have an IBOutlet.
See the outlet indicator next to the IBOutlet?
Click on it!
For additional Xcode shorcuts, a great resource is this PDF maintained in github:
http://cloud.github.com/downloads/Machx/Xcode-Keyboard-Shortcuts/Xcode_Shortcuts.pdf
I don't know if there's a keyboard shortcut for jumping from xib to corresponding class header file. But you can do that easily with a few mouse clicks:
Select a UI object in storyboard
Select "Identity inspector" in Utility Panel (3rd tab from left)
Click right-pointed arrow in the class name text field on top, which will take you to the header file
You can always go back and forth with two-finger swipe in Editor panel
Most shortcuts can be seen here:
http://cocoasamurai.blogspot.com/2011/03/xcode-4-keyboard-shortcuts-now.html
And although that would be an awesome one, don't think it exists.

What is a class outlet and where is it?

I am trying to learn iPhone development and someone passed along the website www.appsamuck.com. On Day 1, the tutorial instructs the developer
We need to reference the label in our code so we can update the label
* In the document window "File's Owner"
* Click: Tools->Idenity Inspector
* In the inspector click the + under "Class Outlets"
* Change myOutlet1 to "countdownLabel"
* Change id to UILabel
* Click enter to make sure they commit
I really don't want to get hung up on this, but I can't find "Class Outlets" either when creating a new project from scratch or opening the zipped source code project. Is this just a difference in versions of Interface Builder? Where did it go?
Class outlets are used to connect objects defined in Interface Builder with ivars and properties defined in the source code. The feature you are looking for has moved since the tutorial was written.
In version 3.2.2, you want to click the File's Owner in the document window. Open the Object Inspector and click on the Info tab icon. Here you can set the class name. You can click the gray arrow in the class name text box or open the Library window. In the Library window click the Classes tab at the top then click the Outlets tab at the bottom. This is where you will see the list of outlets and can add or remove outlets.
Here's a screen shot that might make it easier to follow the steps:
http://skitch.com/kirbyt/n6wm3/classoutlets
Hope that helps.
-KIRBY
Yes, there are various flavors of the Interface Builder that comes with XCode. Especially 3.0 and tutorials written prior that version are a serious pain. You can find the Class Outlets in the Inspector pane. The icon that is blue with a little 'i', is where you should click on.

Resources