I have some 10 buttons with different names each.On selecting each button I need to append the button's title to NSTextField without removing the older string.
I have tried in the following way.
- (IBAction)nextButton:(NSButton*)sender
{
int tag = [sender tag];
if (tag==1) {
[resultField setStringValue:[sender title]];
}
else if (tag==2) {
[resultField setStringValue:[sender title]];
}
else if (tag==3) {
[resultField setStringValue:[sender title]];
}
else if (tag==4) {
[resultField setStringValue:[sender title]];
}
else if (tag==5) {
[resultField setStringValue:[sender title]];
}
else if (tag==6) {
[resultField setStringValue:[sender title]];
}
else if (tag==7) {
[resultField setStringValue:[sender title]];
}
else if (tag==8) {
[resultField setStringValue:[sender title]];
}
else if (tag==9) {
[resultField setStringValue:[sender title]];
}
else if (tag==10) {
[resultField setStringValue:[sender title]];
}
}
Here resultField is my NSTextField.
setStringValue overriding the new string,so that I couldnot able to append string to NSTextField.Is there any easy way to implement this or else use NSString value to hold the previous string and set this string to NSTextFiled along with new button's string value.