¿Cómo se establece el texto en un NSTextField?


Estoy tratando de establecer el texto en un NSTextField, pero los métodos -setStringValue: y -setTitleWithMnemonic: no están funcionando. Alguna idea?

Author: rptwsthi, 2010-05-15

6 answers

setStringValue: es la manera de hacerlo. Debe asegurarse de que su toma de corriente esté configurada correctamente. (En el depurador, asegúrese de que la variable textfield no sea null.)

 200
Author: Ken Aspeslagh,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-04-29 12:14:47

Simplemente haga algo como esto:

myLabel.stringValue = @"My Cool Text";
 32
Author: Jim,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-04-18 07:08:57

Solo myLabel.stringValue = "MY TEXT" funciona aquí, usando Swift y Xcode 6.

 9
Author: Alexander,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-07-14 02:19:33

Swift 4

self.yourTextField.stringValue = "Your_Value"

Nota: Obtener valor de self.Yourstextfield.stringValue en que recibirá el mensaje de advertencia es decir, Mensaje de Advertencia Para evitar este tipo de advertencia se puede utilizar de esta manera (forma sugerida)

DispatchQueue.main.async {
 your code ... 
} 

O también refiérase a esto .

 4
Author: Maulik Rajani,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-12-13 17:05:08

Objetivo:

[label setStringValue: @"I am a label"];

El código original que uso en mi código para mostrar la versión de la aplicación es:

    [lblVersion setStringValue:[NSString stringWithFormat:@"v%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]]];
 0
Author: Alp Altunel,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-03-30 13:11:19

Solo haz esto

[textField setString:@"random"];
 -3
Author: Joe Manto,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-06-02 01:08:40