How do you set the text in an NSTextField?

前端 未结 7 2217
孤城傲影
孤城傲影 2020-12-08 12:39

I\'m trying to set the text in an NSTextField, but the -setStringValue: and -setTitleWithMnemonic: methods are not working. Any ideas?

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-08 13:20

    If the value you're trying to set happens to be an integer rather than a string, you don't need to convert the integer value to a string manually; you can just call:

    myLabel.integerValue = i;
    

    The integerValue property is defined on NSTextField's parent class, NSControl. See that linked documentation page for a full list of methods it supports.

提交回复
热议问题