H. Daniel
H. Daniel

Reputation: 5

enum cannot be constructed because it has no accessible initialisers

I'm trying to achieve some sort of "walkthrough" part, which the user should be able to "swipe" through. I have run into this issue "PageTut cannot be constructed because it has no accessible initialisers"

The two components are in different packages, I even tried setting the struct as public but still didn't work

I've looked it up, but I just cannot find something useful to solve my issue and it's actually getting frustrating. Anyone knows how can I solve the issue? Any help or idea would be much appreciated

import UIKit

public struct PageTut {

    let TutTitle: String
    let TutDescr: String
    let TutImageSrc: TutImageSrc

    public enum TutImageSrc {
        case name(String)
        case src_url(URL)
    }

}

and in the other file

import UIKit

class TutViewController: UIViewController {

    private var pages = [PageTut]()

    override func viewDidLoad() {
        super.viewDidLoad()
        configPages()
    }

    private func configPages() {
        pages.append(PageTut(TutTitle: "", TutDescr: "", TutImageSrc: PageTut.TutImageSrc("")))
    }
}

Upvotes: 0

Views: 148

Answers (1)

Stamenkovski
Stamenkovski

Reputation: 1044

PageTut(TutTitle: "", TutDescr: "", TutImageSrc: PageTut.TutImageSrc("")) 

should be

 PageTut(TutTitle: "", TutDescr: "", TutImageSrc: .name("your image"))

Upvotes: 1

Related Questions