How to add to, not overwrite, an output on xcode
I have a function that outputs a number to a multi-line text field. Currently, I set the contents of the text field with
[outputField setFloatValue:side];
(the name of the text field is "outputField" and the n开发者_开发知识库ame of the variable I am putting in the text field is "side"). I don't think I can make "side" a string because I'm dividing two numbers to get the value of "side". Sorry if this is a dumb question it is my first xcode project.
Assuming you want to add side
to a new line preserving all the previous text and side
is a float:
outputField.stringValue = [NSString stringWithFormat:@"%@\n%f",outputField.stringValue,side];
outputField.text = [NSString stringWithFormat:@"%@%f",outputField.text,side];
精彩评论