Xcode: connecting interface elements to each other
Submitted by robin24 on Monday, July 15, 2013.
Hi all! I'm getting into app development with Xcode, and have started this by reading a book on Objective-C development. This way I was able to familiarize myself with this programming language, and have been exclusively developing applications for the command line for this purpose. Now it's time for graphical applications, and I've been playing around with Interface Builder for the last few days. At this point, I neither hate nor love it, but I think it can mostly be handled once you kind of figure out how things are done. For example, I like how I can arrange interface elements using coordinates in the Size Inspector, run the application and then use my trackpad to verify elements are arranged in the way that I wanted. I've also been able to find out how to connect elements to code, so that I can program and process events and such. However, I am unable to figure out how to connect elements to each other. Basically, I'd like to put a label and a slider in a window, and the slider should update the value of the label. This is an exercise from a Cocoa book that I'm currently reading, since it apparently is possible to control-drag elements to each other in order to connect them. However, control-dragging is not possible with VO, and dragging an event from the Connections Inspector to the other element also doesn't seem to work. Please, could someone help me out here and tell me what I need to do to connect 2 elements to each other? Many thanks! Best wishes, Robin.
Hi, I'm sorry to say I don't have an answer to the question you pose, but I do have a question. Which code books are you working out of? I've been wanting to get into app development myself but have no idea where to begin. Thanks much.
I have been wanting to get in to app development but I don't have a mac so I don't know the answer to this question but I can research this.
Hi, as for Objective-C learning, I read Programming in Objective-C, Fifth Edition by Stephen G. Kochan. It's a great book for learning Objective-C, and I think the author did a great job in explaining all the concepts of the programming language. Note that you will only be developing applications for the command line in this book, all the fancy stuff comes afterwards! As for learning Cocoa and designing applications with visual interfaces, I've found 'Learn Cocoa on the Mac, Second Edition' by By: Jack Nutting and Peter Clark. I haven't read too much of it yet, but it seems rather detailed and explanations seem thorough. My main problem right now really is dealing with Interface Builder issues, as I find the rest of Xcode rather easy to use. I should also say that the mentioned books are available online through http://www.safaribooksonline.com. You will need a subscription with them to get access to their content, but if you're interested in learning programming languages and such I highly recommend them. Hope that helps! :-) Robin
Open the assistant editor (from the toolbar) in xcode (it'll open two views side by side, one view with the xib and the other with the corresponding .h file). control drag from your label to the created property
Thanks for your research, but that's exactly the problem - you can't do control dragging with VO... That's just how you'd do this with a mouse or trackpad, but it can't be done using VO :-( Robin
Hi, robin24. I'm a sighted developer and have an app with a slider that updates a label. I'm not aware of any way to connect the slider to the label with a control-drag. I'd be curious to learn that this is possible if you can provide a specific citation. What I do is connect the slider to an IBAction, and then update the label there. I can provide specific code if you'd like.
Disclaimer: I'm a sighted developer, so I have no idea if what I'm about to describe here is doable with VoiceOver on a Mac. Here's one way I know of to connect Interface Builder elements to IBOutlets in your .h file. 1. Open NIB/XIB file in interface builder's standard editor. 2. Double-click the corresponding .h (header) file so that it opens in a new window. 3. In your header file, on the line which has your IBOutlet, to left of where the line number is listed by XCode, there is a small spot which you can drag (without control) onto your interface builder element in XCode's main window. This should allow you to connect Interface Builder element with the IBOutlet.