How can I find the file my storyboard outlet connects to? - swift

This may be a silly question.
I know I can easily go to my storyboard from my outlet e.g.
Is there an easy way to do the reverse? I'd like to go from my storyboard element to my swift file, specifically the line of code where the outlet is declared.

I'm not aware of any shortcut link back to the declaration of an outlet. A couple of alternatives are:
Use the Assistant Editor (it's the middle button below with the two overlapping rings) while you have a View Controller or an element within it selected in a storyboard. It will load up the accompanying class in a panel beside the storyboard view.
Select the View Controller itself out of the hierarchy, go to the Identity Inspector on the right, and tap the little gray circle icon with a white arrow in it beside the class name. That will take you to the class file in the main editor.
Those are the only two methods I know of for getting to the associated class.

Select the element and then click "Show the Assistant editor" at the top right. It will take you to the correct class, but not to the exact line it is declared on.
Select element:
Click "Show the Assistant editor":

Related

How to swipe out of table view controller (not the cells) - iPhone

I have a tab bar app. It has 5 tabs. I have the 3rd tab connected to a navigation controller that's connected to a table view controller. Simple enough, right?
Well, I recently decided to implement left/right swipe gestures as an optional way to navigate left and right to each tab in the tab bar controlled app. The gestures work great, except I don't have a way to implement the gestures on the 3rd tab (the one with the UITableView) because there's no implementation file associated with it.
And that's my question: How can I implement the gestures on the third tab so I can navigate AWAY from it by swiping?? I can swipe into that tab, but not out of it. I'm fairly new to iOS dev, and I really appreciate any help!
(Using ARC, Storyboard, & Xcode 4.5.2)
EDIT:
Here's a screenshot of how my Table View Controller is connected to my Tab Bar Controller:
SOLUTION:
The answer marked correct is indeed correct. It explained to me how to make a subclass of my UITableViewController. But I was also wondering how to implement my TableView programmatically... so after a bit of searching, this link pretty much shows exactly how to do that: Ruchi Raval's post on mobisoftinfotech. However, I ended up just following the steps in the link, and I ended up deleting my original UITableViewController because I had created a new one through the steps in the link and connected it to my NavigationController through the Storyboard (ctrl + drag).
Hope this helps anyone that had my same quesions!
To control gestures on a VC, you'll need your own subclass. Create a new objective-c object named like MyTableViewController. Xcode lets you specify a superclass when creating the files, use UITableViewController.
Xcode provides some template code in the new files -- leave that alone to begin with. In storyboard, I think the tab you're trying to fix has a navigation (vc) whose root vc is a UITableViewController.
Select that table vc and select the Identity inspector (upper right, third tab from the left). You should see a section called custom class. The current class is probably UITableViewController. Change that to MyTableViewController, or whatever you named the new class.
Build and run. Now you control that table vc. Back in it's implementation file, you can add your gesture code in viewDidLoad:.

Why XCode 4 doesn't create XIB file when using storyboard?

Why can't XCode 4 create XIB file while using storyboard: is it 2 incompatible models ? For example all tutorials about hiding keyboards seem to require XIB file:
http://www.techotopia.com/index.php/Writing_iOS_4_Code_to_Hide_the_iPhone_Keyboard_%28Xcode_4%29
Here is an update to the link in the question:
Having written the code for our method we now need to wire up our user interface so that it gets called at the appropriate time. We will perform this task in Interface Builder, so select hideKeyboardViewController.xib once more.
The equivalent of this now is to click on storyboard, and then click the hidKeyboardViewController in the storybaord window.
Select the text field in the view and display the Connections Inspector (View -> Utilities -> Connections Inspector) in the right hand panel.
The equivalent of this now is to Right click the text field.
Click on the circle to the right of the Did End on Exit event, drag the line to the File’s Owner icon and select textFieldReturn from the list of available methods.
Equivalent here is to click the circle, as mentioned, then drag the blue line to the orange box at the bottom.
Its the same, inside the storyboard you will see your views and you can do the same as you did when you were working directly with .xibs
Treat the "scenes" in the storyboard as if they were XIBs. You can layout the screen, add elements, and link them up to their respective ViewControllers. Any code you need to run should be in a ViewController, and then in the Storyboard you can indicate that a particular scene is related to that ViewController.
For your question about hiding the keyboard, you'll need to have a method in your ViewController that includes a line of code:
[myTextField resignFirstResponder];
...where myTextField is a UITextField, UITextView, or other object that requires a keyboard.

Xcode issue - cannot connect button to object

I seem to be having an issue. The tutorial I am following from Apple's Dev Center says:
Control-drag a connection from the
Convert button to the
ConverterController instance in the
nib file window.
A black box will pop up similar to
the one we used to connect outlets.
Choose convert:.
Save the nib file.
I usually hold ctrl and drag the mouse from one object to another. However, when selecting a button from my User Interface and trying to drag to an Object in the xib window (this is all in the Interface Builder), the object will not highlight. It just won't let me do it!
Any ideas why this is happening?
you can use the "tree" map of all the objects in your nib file so it is easier to select one. this is helpful if they are on top of each other, hidden, or otherwise difficult to click directly. in xcode 4, there is a little triangle button along the bottom left of the nib view; if you click it, a sidebar opens with a text outline of all your nib's object. you can click the button in this list so it highlights, then control-drag to your file owner to attach it to a method you have written. the sidebar is also useful if you want to re-order objects in a view or subview, to make some on top of others.
Right click the file owner file a pop up will appear in front of you their you can see various action methods that you have in your project.
select a particular action method and then assign it to the appropriate button on which you want to call the appropriate function.

Connecting file owner to app delegate

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?
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.
I had this same problem. I found a lot of half-answers on different threads, so I decided to put them together here.
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.
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.
Control-drag from the File's Owner to the new object, which should not be displayed as " App Delegate", and select delegate.
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.
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.

In XCode 4, how do you change the number of tabs in a UiTabBarViewController?

I've been looking at this new interface for a while now and I can't figure out how to add or remove tabs from the tab bar.
Any help would be appreciated.
There are two possibilities:
1 - Open your xib-file inside Xcode. Show the right sidebar (Navigator | Utility). At the bottom of this bar should be all Interface Builder objects (i.e. UITabBarItem, UILabel, ...). Now drag a UITabBarItem to your View.
If you don't see these objects: At the bottom is a small cube. press it and you'll see it.
2 - Right-click on your file and open in external editor. This opens Interface Builder. If it won't work you can open your file directly with the Interface Builder.
You ask this question in the Apple Developer Forums where you can talk about confidential information (read: NDA software). Xcode4 is not yet available for public consumption, therefore it's still under NDA.
I also work around on find out how to set the tabitem in Xcode4, I found you just drag the controller to the tabitems, the select the uiview of this tab item and set it's class. Xcode on longer support set tab item at the inspect panel.
Assuming that your Tab Bar was created in XCode (which it should be if you created a Tab Bar project) click on your Main Window.xib to view it.
Click the disclosure indicator to see the hierarchy of objects (if it isn't that way already).
It should look something like this:
The number of view controllers that you have underneath it is the number of tabs you have.
In this case the view controller is a Navigation Controller, and the View Controllers are children of it.
If u r using Story board .........
Just do this ...
and i am telling for Xcode 4.3
just add view controller from the libirary you can add as much as you like..
then link those views with your main view controller...
as you will link with it ....
it will automatically pop up relationship with main controller and thus a tap will be added automatically in your main controller...
you can visit this link ....
"http://www.youtube.com/watch?v=qvvJzkJcsew"