Can't create outlets in File's Owner on Xcode 4.5.1

Hi,

Thanks for looking.


I'm having issues with xcode 4.5.1. and i am new to developing.


I'm trying to build a basic UIWebView page and don't have the viewcontroller.xib on the left hand side, i've seen a post which told me how to make one. it worked but once i type the programming into the viewcontroller H+M screens then go back to the page, drag and drop the UIWebView object into the page it won't let me put the outlet onto the page, it just comes up with "delegate"


Any help would be great


Regards


Craig

MacBook Pro, Mac OS X (10.7.4)

Posted on Oct 20, 2012 9:13 AM

Reply
23 replies

Oct 20, 2012 9:32 AM in response to Craigv513

Well there seems to be two avenues for getting into XCode, and Apple seems to be advancing both of them.


The first way is to accept the pre-formatted styles and forms that apple is trying to create to make using x-code easier for new comers. If you can envision your app with a main menu, one or more windows, and a data base (which almost all apps can conform to) and you don't have too much desire to get into the fundamentals, then you can just stick with a document based application (which starts you off with a view, a view controller, and a data base if you want one).


If you find yourself constantly trying to change things that won't change, or trying to understand what does what and why, then you'll have to go the different route, and start from C to ObjectiveC, and learn a little more about the reasons for the steps that led to the Cocoa platform.

Oct 20, 2012 9:39 AM in response to mark133

For the first route, it sounds like you just need to clearly recognize that the view controller .h file is mainly a reference for the view controller .m file. The view itself (the .xib file) is connected behind the scenes to the view controller .m file. Then you can get into the details of connecting specific buttons and outlets from the view (the .xib file) to the view controller, and adding the code that you want to add.


For the second route, you need to start off with what an object is.

Oct 20, 2012 9:58 AM in response to mark133

my intention eventually is to become proficient in programming and maybe publish an app to the app store.


i noticed the .h and .m views were linked, i start with the basic templates. Then use the drag and drop object libraries to add button, titles etc.

My biggest problem is the joining of the outlet file i write to the actual page, when i try to find the File's Owner button its not there and i can't work out how to do it from the right hand inspector.


But when i used NEW-FILE-WINDOW route i get the .xib viewcontroller and the file's owner button but nothing shows in the file's owner button except the Delegate option?


the coding i'm typing is identical to those used on you tube and it has no errors,


i knew it wouldn't easy. ha. I was right.

Oct 20, 2012 10:11 AM in response to Craigv513

You can easily generate a marketable app using the basic templates. I bought a little school math app for my sons a few years ago, and it worked great. That was before I knew anything about Cocoa, but I'm still happy with that little app.


So it sounds like the next big problem is figuring out how to join the controls and outlets to the controller. That is a huge problem and it's difficult for newcomers to figure it out.


The main step is that you have to have an IBOutlet as an instance variable in the view controller before it will show up as a possible connection in the .xib design platform.


Alternatively, you can drag a button, etc, using control-click, into the instance variable portion of a view controller.

Oct 20, 2012 10:39 AM in response to mark133

It sounds like you are dragging the outlet to the application's folder? Anyway, that's not how it works. What you have to do is open the assistant editor window when the .xib file is open. The assistant editor will open next to or else under the .xib file. Then you open the controller file (I think you have to open the .h file) in the assistant editor window. You drag the outlet linker thing to the instance variable area of the text of the opened controller file.


All this does is add an IBOutlet instance variable to the controller. You can add it yourself by typing it, and then link the outlet from the available outlets using control-click or click and drag. That's another thing that makes the linking or creating of outlets and controls difficult to understand. There are like three or four ways to make an Outlet or controller with a linked variable.


The main idea is very simple. The .xib file makes a link behind the scenes to any IBOutlet type of variable. It makes the most sense to me to think of adding the IBOutlets by typing them into the file, and then selecting those for linking by using control-click on the field or button displayed in the .xib design platform. Then the process of dragging and dropping onto an open file to create the IBOutlet can be seen as a convenience. Otherwise, the process of dragging and dropping seems like a necessity, and the whole understanding of the variables and the application gets confused.

Oct 20, 2012 10:34 AM in response to mark133

here's what i type. I understand its a bit trying but thanks for your help.


in the .h script it type


{ IBOutlet UIWebView *myWebView; }


thats under the @interface line,


then in .m controller i type this under the super viewdidload line,


NSURL *myURL = [NSURL URLWithString:@"http://www.google.com"];


[NSURLRequest requestWithURL:myURL];


[myWebView loadRequest:myRequest];


then when i try to link the outlet to the page i cant find a file owners button.

the only way i can build the UIWebView page with dragand drop is in the main storyboard view because i have no standard .xib view.


hope that makes sense.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Can't create outlets in File's Owner on Xcode 4.5.1

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.