Swift - "Use of Unresolved Identifier"

Use of Unresolved Identifier' in Swift

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.

Targets

Use of unresolved identifier Form

Beta 2 has introduced form.

The difference to List is that it can not be initialized with a data collection.

public struct Form<Content> where Content : View {

public init(content: () -> Content)

public var body: _View { get }

/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required `body` property.
public typealias Body
}

Swift - use of unresolved identifier

1) Right Click your MainViewController.swift

2) Select Show File Inspector

3) On Right side panel, look at Target Membership

4) Add your class to target by check the box :)

Use of unresolved identifier 'questionList

If the questions are hard-coded move them into the Question struct as class property

struct Question {
let questionString: String
let answers: [String]
var selectedAnswerIndex: Int?

static let questionsList : [Question] = [Question(questionString: "What is your favorite type of food?", answers: ["Sandwiches", "Pizza", "Seafood", "Unagi"], selectedAnswerIndex: nil), Question(questionString: "What do you do for a living?", answers: ["Paleontologist", "Actor", "Chef", "Waitress"], selectedAnswerIndex: nil), Question(questionString: "Were you on a break?", answers: ["Yes", "No"], selectedAnswerIndex: nil)]

}

and call it from everywhere

Question.questionsList

Use of unresolved identifier error when calling array in my extension code

You are extending ViewController (which is the default empty view controller provided by an app template) instead of MainViewController. ViewController in its template form does not have rList as member, thus the error.

Change your extension to:

extension MainViewController: UITableViewDelegate, UITableViewDataSource {
.
.
.
}


Related Topics



Leave a reply



Submit