助理编辑器显示不同的“ViewController.swift"文件比主编辑器显示的文件?
辅助编辑器中显示的ViewController.swift"源代码与主编辑器中显示的ViewController.swift"源代码不同.
The source code shown in the Assistant Editor for "ViewController.swift" is different than source code shown in Main Editor for "ViewController.swift".
主编辑器
中的ViewController.swift":
"ViewController.swift" in Main Editor
:
// ViewController.swift
// FoodTracker
import UIKit
class ViewController: UIViewController, UITextFieldDelegate {
// MARK: Properties
@IBOutlet weak var nameTextField: UITextField!
@IBOutlet weak var mealNameLabel: UILabel!
@IBOutlet weak var mainButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
nameTextField.delegate = self
}
// MARK: UITextFieldDelegate
func textFieldShouldReturn(textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
func textFieldDidEndEditing(textField: UITextField) {
mealNameLabel.text = textField.text
}
// MARK: Actions
@IBAction func setDefaultLabelText(sender: UIButton) {
mealNameLabel.text = "DEFAULT text"
// mainButton.tintColor = UIColor.darkTextColor()
}
}
Assistant Editor
中的ViewController.swift":
"ViewController.swift" in Assistant Editor
:
//
// ViewController.swift
// FoodTracker
import UIKit
internal class ViewController : UIViewController, UITextFieldDelegate {
@IBOutlet weak internal var nameTextField: UITextField!
@IBOutlet weak internal var mealNameLabel: UILabel!
@IBOutlet weak var mainButton: UIButton!
override internal func viewDidLoad()
internal func textFieldShouldReturn(textField: UITextField) -> <<error type>>
internal func textFieldDidEndEditing(textField: UITextField) -> <<error type>>
@IBAction internal func setDefaultLabelText(sender: UIButton) -> <<error type>>
}
所以,这些是完全不同的不同文件,但具有相同的名称.Assistant Editor
中的那个是interface,而Main Editor
中显示的文件是接口的实现,对吧?
So, those are completely different different files, but have the same name. The one in the Assistant Editor
is the interface while the file shown in the Main Editor
is the implementation of the interface, right?
这看起来有点奇怪,但是接口和实现类同名?当我在 Xcode 中工作时,我需要注意有时两个文件可以(通常?)具有相同的名称?
That seems a little weird, but the interface and implementing class have the same name? When I'm working in Xcode I need to be aware that sometimes two files can (often?) have the same name?
我遇到了同样的问题.我不明白为什么它会显示这个内部类"文件.
I had the same problem. I couldn't figure out why it was showing this "internal class" file.
我设法让它显示正确的关联文件.为此,请单击相关的编辑器图标,即两个圆圈.然后在出现的窗口中,单击+".出现的新窗口中应该有正确的代码.然后关闭旧窗口,您应该留下正确的窗口.该项目的其余部分现在似乎已修复.
I managed to get it to display the correct associated file. To do this, click the associated editor icon, the two circles. Then in the window that appears, click the '+'. The new window that appears should have the right code in it. Then close the old window and you should be left with the right one. The rest of the project appears to work be fixed now.