xcode - Applescript Xcode,我需要读取文件并在标签上不断显示更改
问题描述
当我更改 TextField 内容时,我拥有的代码会更新标签,但这不是我需要的:
property aTextField : missing value
property aTextLabel : missing value
on controlTextDidChange_(aNotification)
log aTextField's stringValue
aTextLabel's setStringValue: aTextField's stringValue
end textDidChange_
我需要类似的东西:
property aTextLabel : missing value
on applicationWillFinishLaunching_(aNotification)
repeat
set MyFileTextContent to (do shell script "cat /Users/Johann/Desktop/myLabelValue.txt")
aTextLabel's setStringValue:MyFileTextContent
end repeat
end applicationWillFinishLaunching_
但显然这不起作用,但我不知道如何实现我的目标。
解决方案
解决方案:
property NSTimer : class "NSTimer"
property myTextField : missing value
on log1:sender
performSelector_withObject_afterDelay_("log1:", missing value, 1.0)
set myText to (do shell script "cat texFile.txt")
myTextField's setStringValue:myText
end log1:
on applicationWillFinishLaunching:aNotification
performSelector_withObject_afterDelay_("log1:", me, 0)
end applicationWillFinishLaunching:
推荐阅读
- scala - 具有不同类型的处理和数据帧的单个读取流到多个写入流
- docker - 在 Redhat 8 上安装 docker-ce
- javascript - 如何在单个变量下为下拉列表设置多个值?
- php - 通过 laravel 5.4 maatwebsite 包导出时,数字未在 ms excel 中转换为印度货币格式
- php - 结合 OnsenUI 应用程序和 Wordpress 网站
- java - Java EE WebApp ServiceLoader 将外部 jar 作为插件加载
- c# - 是否可以对在反编译过程中变得混乱的反编译 C# 代码进行逆向工程?
- ios - iPad屏幕在swift 5中自动调整大小
- css - 如何使用 React-Bootstrap 映射()项目
- java - 我可以在同一个 Spring Boot 应用程序上使用两个拦截器吗?