使用xcode 6.1(OSX)在Swift中解决NSTextField的问题 [英] Trouble with NSTextField in Swift using xcode 6.1 (OSX)

查看:90
本文介绍了使用xcode 6.1(OSX)在Swift中解决NSTextField的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我启动了Swift,但没有启动ObjectiveC.有人可以教我如何在OSX下使用xcode 6.1在Swift中获取和设置NSTextField吗?

I started Swift but not Objective C. Can someone teach me how to get and set the NSTextField in Swift using xcode 6.1 under OSX?

推荐答案

您可以使用stringValue属性获取并设置NSTextField的值.例如,如果您的应用程序中有此@IBOutlet:

You get and set the value of an NSTextField with the stringValue property. For instance, if you have this @IBOutlet in your app:

@IBOutlet weak var textfield: NSTextField!

获取值:

println("textfield is \(textfield.stringValue)")

设置值:

textfield.stringValue = "this is my string"

这篇关于使用xcode 6.1(OSX)在Swift中解决NSTextField的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆