Objective-C, how to define a handler for a button click?

I am a C ++ and Javascript developer who teaches objective-c to be a cocoa / objective-c programmer for basic Mac OSX desktop applications. I am very green when it comes to objective-c / cocoa, and I was wondering how can I add a button to my main mode and associate a custom handler with this button when pressed? What is the best way to do this? I have done this many times with wxWidgets, but this is my first cocoa app to help me learn and wet my feet.

I would also be grateful for any book suggestions or learning resources that you might pay attention to.

Thank!

+3
source share
1 answer

Alex, I would highly recommend you check out some books before diving into Objective-C. Based on C ++ and Javascript, you will need to better adapt your thinking to what you are going to learn, and if you do not prepare, you will be very, very confused. As said quixoto, definitely take a look at Aaron Hillegass Cocoa Programming for Mac OS X as it guides you through the process of building applications and using Xcode and Interface Builder. However, before that, I strongly recommend that you check out Stephen Kochan Programming in Objective-C 2.0 to get a tutorial on the language and its concepts (although C ++ and Objective-C are supersets of C, they are both completely different).

+4

Source: https://habr.com/ru/post/1782188/


All Articles