Swift 中“未解析标识符的使用" [英] 'Use of Unresolved Identifier' in Swift

查看:44
本文介绍了Swift 中“未解析标识符的使用"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我一直在制作一个应用程序,一切都运行良好.但是今天我像往常一样创建了一个新类,出于某种原因,在这个类中我无法从其他类访问公共/全局变量.所有其他课程都可以,但现在每当我尝试创建一个新课程时,我都做不到.这将如何解决?

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"

use of unresolved identifier "signedIn"

推荐答案

一个可能的问题是你的新班级有一个不同的 Target 或与另一个不同的 Targets.

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屋!

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