处理脚本,并尝试查看import UIKit
class ViewController: UIViewController {
@IBOutlet var Cat: UITextField!
@IBOutlet var resultLabel: UILabel!
@IBAction func FindCatAge(sender: AnyObject) {
var enteredAge = Cat.text.toInt()
if enteredAge != nil {
var catYears = enteredAge! * 7
resultLabel.text = "Your cat's age is \(catYears) In cat years"
} else {
resultLabel.text = "Please enter a Number"
}
func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
命令在以下代码中无效的原因。它将创建文件,但不会向其写入任何内容。我错过了什么吗?
Out-File
答案 0 :(得分:1)
您正在使用Out-File
管道传输到Write-Host
,但Write-Host
cmdlet不会传递任何内容。你可以通过一个简单的例子来检查它
Write-Host "Something" | Write-Host
“Something”只会输出一次。
你应该避免在你的脚本中使用Write-Host
,这是一个经验法则,这就是Don Jones一直以来所说的。请参阅here您最好用Write-Host
代替什么。
要更正您的脚本,您只需省略Write-Host
,就像这样
"Time at $server is $SUTC. Time difference of $Difference." | Out-File $logfile -Append