gpt4 book ai didi

iphone - cocoa 中的 'variable' .text 相当于什么?

转载 作者:行者123 更新时间:2023-12-03 18:00:46 25 4
gpt4 key购买 nike

在 iPhone 应用程序中,我可以毫无错误地编写类似的内容(并且有“someThing”标签。:

NSString *thing = someThing.text;

但我正在尝试在 cocoa 中做到这一点。我需要将标签“someThing”上的文本设置为“thing”。它在 Cocoa 中不起作用,但在 iOS 中起作用。有什么想法吗?

谢谢

最佳答案

Cocoa 类不使用那么多属性 (.foo),而是使用 getter ([object foo]) 和 setter ([object setFoo:value])。实际上,属性只是 valuesetValue: 方法的包装。

要设置 NSTextField(标签)的文本,您可以使用 [myLabel setStringValue:@"Hello World!"]

要获取其值,您可以使用NSString *string = [myLabel stringValue]

NSControl 的大多数子类都实现了 stringValueintValue

关于iphone - cocoa 中的 'variable' .text 相当于什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6838807/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com