Swift中“使用未解析的标识符” [英] 'Use of Unresolved Identifier' in Swift
问题描述
所以我一直在制作应用程序,一切都运行良好。但今天我像往常一样创建了一个新类,由于某种原因,在本课程中,我无法从其他类访问Public / Global变量。所有其他课程都可以,但现在我尝试创建一个新课程时,我不能。如何修复?
So I have been making an app, and everything has been working great. But today I made a new class like usual and for some reason in this class I can't access Public/Global variable from other classes. All the other classes can, but now when ever I try to make a new class I can't. How would this be fixed?
我使用的是Swift和Xcode 6.
I am using Swift and Xcode 6.
工人阶级:
import UIKit
import Foundation
import Parse
import CoreData
var signedIn = true
class ViewController: UIViewController {
新类:
import UIKit
class NewClass: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
signedIn = false
}
但是 signedIn = false
我得到使用未解析的标识符signedIn
推荐答案
一个可能的问题是您的新班级有不同的目标或来自另一个目标的不同目标。
One possible issue is that your new class has a different Target or different Targets from the other one.
例如,它可能有一个测试目标而另一个没有。对于这种特定情况,您必须在测试目标中包含所有类,或者不包括任何类。
For example, it might have a testing target while the other one doesn't. For this specific case, you have to include all of your classes in the testing target or none of them.
这篇关于Swift中“使用未解析的标识符”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!