I am trying to print “.” when I press on a button that shows “.”
Basically I wanna grab “.” on NSString format
So if I do
NSString *dec = [sender currentTitle];
it just crashes when I try to run.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In Cocoa, all controls send notifications that they have been operated, by using a target-action mechanism. The ‘target’ is any other object and the ‘action’ is any selector that that object responds to. Buttons are no different.
So you can, for example, define:
You’d hook that up to the button’s target-action, by invoking
-setTarget:and-setAction:accordingly. The target will beself, if you’re doing this from inside the class that handles the action:Now when the button is pressed, you’ll get a NSLog() output in the console.
To update the value of a label instead of printing something with NSLog(), you can probably figure that out, but:
You should read Apple’s documentation, which covers this stuff in great detail.
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/CommunicateWithObjects.html#//apple_ref/doc/uid/TP40002974-CH7-SW14
PS: stackoverflow is for all programming languages, so make sure to tag your questions with the relevant programming language.