Cocoa Programming L4 – Making Connections




How to make connections in Cocoa between your code and your interface.
Sorry for making it over 20 minutes!!!

source

33 thoughts on “Cocoa Programming L4 – Making Connections”

  1. I have followed i believe this tutorial, but i get an app delegate instead of the app controller class. Why? should I add the app controller class myself?

  2. Check from 1:20 on. We create the AppController class and then later we add the object in Interface Builder to connect our outlets/actions.

  3. Oops . . . was watching last night and continued today but wasn't mirroring you just picking up from the middle of my own project. Thanks, these tutorials are very nice and are getting me updated from 90s era Unix C coding from the command line . . . .

  4. I created a second button and tied it to a second method that puts a different message in the label. Looking at the connections there is no way to easily verify which button is calling which method . . . is there a way to edit the text of the xib to see these connections more explicitly?

  5. @15:20 if you right click the App Controller, in the overview popup window it shows all the connections and as you hover over each connection it will highlight the actual object (button or label) which it represent. If you have two buttons connected to two diff methods it will highlight the appropriate button on hover.

    I am not sure, if XCode generates a text of xib, in the previous versions (Xcode 3.x) it did not do so, but that was a while ago, not sure about this version

  6. You are allowed to intertwine Obj-C with C++ (Obj-C++) however I'm not familiar with how it works in terms of Cocoa and making connections in interface builder. You'd still have to use Obj-C for that but if you google Obj-C++ you should find a lot of useful information.

  7. If you manually alloc init the button in your AppController and then place it on the window then yes you can. Obviously one is easier than the other though.

  8. Haven't yet, nope. Unless you have a very good reason not to use interface builder for it then I would advise against it. Interface Builder has been around since the beginning of the platform and is as much part of Cocoa as the code base is. Do you have a particular reason why you would like to do it manually?

  9. It's kinda the programmers motto, why make more code when you don't have to. Yes you can create a button and manually add it as a subview and then tell it the action it will send to a specific target and then deal with how it's going to be aligned in the window. But why would you want to :). Steve Jobs flaunted this feature of NextStep when he brought it to Apple.

  10. Is there any way to display 2 different messages every time you click the button? I noticed that every time I hit the button, the sayhello method is executed but it seems it cannot retain any value in it after?

  11. I love your tutorial very much , I've just watch only 3 lesson. I used to programing by visual basic, but I leave it for a long time, Now I buy Apple and I know Xcode it's amazing, Thank you very much for your tutorial. I'm watching cocoa programining . Do I have to learn another lesson before?. Is Object C programing recommend ?

  12. My advice is to find another video series. This guy repeats everything he says verbatim three times in the current lesson and then in next lesson he reviews the last lesson before he starts something new. Go to iTunesU/Stanford and take any of the courses taught by Paul Hegarty. You will learn objective c much more efficiently and make better use of your time.

  13. What if you wanted to insert thousands of nsbuttons into a button matrix 🙂 There are plenty of reasons for wanting to do this. And I cant imagine you wanting to do this by hand.

  14. I can't change the Label's text. I'm using the dev preview of Xcode 5 and setStringValue doesn't seem to exist.

  15. If you're using the assistant editor then yes you can connect the code to the object directly. I just prefer the other way on my small screen and sometimes I think about things in code that I need beforehand so it's easier to just add them there and then jump to interface builder.

  16. When I'm making connections, how do i pair a button with a specific App? im trying to make a hide application that will hide all safari pages and only safari pages. I know i can do this using NSWorkspace, and I know I have to get bundle identifiers for all running applications, but i have no idea how to do any of it. Can you help? thank you so much! Great Tutorials!

  17. You can use NSRunningApplication to get the app by bundle id and then terminate it. You can get the app path with NSWorkspace and NSBundle can get the bundle id for you with the app path. Looking at those 3 classes should get you in a good spot.

  18. Thank you very much… I spent hours in trying to understand Objective-C.
    Finally, I found your tutorials… Thank you.

  19. This is the first tutorial I've come across that explains how to make connections, until now I wasn't even able to figure out how to do a simple "hello world" type GUI application with xcode/cocoa.

    However, coming from primarily a Visual Basic (6) background, the amount of work/steps required to achieve this is quite astonishing. Why the need for such a long winded route to get the same results, example, in VB, double clicking your button takes you into a pre coded method for the click action, then simply add your code, in this case to change/set the label text.

    I'm seeing myself as being too lazy for Xcode/Cocoa which is a shame as I was really looking forward to getting into Apple programing.

  20. When I search for garb in build settings on Xcode 5, the only thing that pops up is Objective-C Automatic Reference Counting. I'm assuming they've replaced Garbage Collection with ARC, so is YES the right value for this?

  21. That's great thanks again Lucas. I actually want to lean how to make Iphone Apps, Is it usefull to listen to theses coco tuts or should I find some specifics cocoaTouch tuts somewhereelse ? If so does anybody know some good ones ? Tks !

  22. Hi Lucas I'm new in this and I found your tutorials. I work with Xcode version 8.2.1 and there's no "Objective-C class with header" available. Only "Cocoa Touch class" which create AppController.h and .m, but the instruction NSTextField is not recognize, am i using the wrong template or which one should I use to make it work, it's not obvious with another version of Xcode. Hope you still following up those tutorials.Thank you.

Leave a Reply