Objective-C, how to define a handler for button press?
I'm a C++ and Javascript developer who is learning objective-c to be a hobbyist cocoa/ob开发者_如何学JAVAjective-c programmer for mainly Mac OSX desktop applications. I'm pretty green when it comes to objective-c/cocoa, and I was wondering how I can add a button to my main view and bind a custom handler to that button when it's clicked? What's the best way to do this? I've done this many times with wxWidgets, but this is my first cocoa application to help me learn and get my feet wet.
I would also appreciate any book suggestions or learning resources that you could point me to.
Thanks!
Alex, I would highly recommend you check out some books before you dive into Objective-C. Coming from C++ and Javascript, you're going to have to better adapt your mindset to what you are going to learn, and if you don't prepare yourself, you're going to be very, very confused. As quixoto
said, definitely take a look at Aaron Hillegass' Cocoa Programming for Mac OS X, as it will walk you through the process of creating applications and using Xcode and Interface Builder. Before that, however, I would highly recommend you check out Stephen Kochan's Programming in Objective-C 2.0, to get a primer on the language and its concepts (although C++ and Objective-C are supersets of C, they are both quite different).
精彩评论