3

I'm trying to create a custom walkthrough for my iOS app using the open source framework BWWWalkthroughController (link: https://github.com/ariok/BWWalkthrough) but I can't get it to work!

Here's the class where the error occurs:

import UIKit

class StartPageViewController: UIViewController, BWWalkthroughViewControllerDelegate {

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

override func viewDidAppear(animated: Bool) {
    super.viewDidAppear(animated)

    let userDefaults = NSUserDefaults.standardUserDefaults()

    if !userDefaults.boolForKey("walkthroughPresented") {

        showWalkthrough()

        userDefaults.setBool(true, forKey: "walkthroughPresented")
        userDefaults.synchronize()
    }
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

@IBAction func showWalkthrough(){

    // Get view controllers and build the walkthrough
    let stb = UIStoryboard(name: "Walkthrough", bundle: nil)

let walkthrough = stb.instantiateViewControllerWithIdentifier("walk") as! BWWalkthroughViewController <----- THIS IS WHERE THE ERROR OCCURS

    let page_zero = stb.instantiateViewControllerWithIdentifier("walk0") as! UIViewController
    let page_one = stb.instantiateViewControllerWithIdentifier("walk1") as! UIViewController
    let page_two = stb.instantiateViewControllerWithIdentifier("walk2")as! UIViewController

    // Attach the pages to the master
    walkthrough.delegate = self
    walkthrough.addViewController(page_one)
    walkthrough.addViewController(page_two)
    walkthrough.addViewController(page_zero)

    self.presentViewController(walkthrough, animated: true, completion: nil)
}


// MARK: - Walkthrough delegate -

func walkthroughPageDidChange(pageNumber: Int) {
    println("Current Page \(pageNumber)")
}

func walkthroughCloseButtonPressed() {
    self.dismissViewControllerAnimated(true, completion: nil)
}

}

Here's my error:

2015-06-29 00:24:02.951 Up & Down - Minimalistic, Beautiful Counter[13041:715011] Unknown class _TtC43Up & Down - Minimalistic, Beautiful Counter27BWWalkthroughViewController in Interface Builder file.
Could not cast value of type 'UIViewController' (0x10570c418) to 'Up___Down___Minimalistic__Beautiful_Counter.BWWalkthroughViewController' (0x103972fb0).
(lldb) 

I have made sure all classes are correctly named in IB, and I'm quite sure everything is correctly linked (outlets, actions, etc.) as well (I have looked at many similar-looking questions with no answers working for me. Any ideas what the problem might be? THANKS!

Alexander G
  • 115
  • 9
  • It looks like you haven't set the custom class for the UIViewController associated with the scene "walk" - It is just a plain UIViewController instance – Paulw11 Jun 28 '15 at 22:44
  • @Paulw11 I think I have though. The class associated with the scene "walk" is: BWWalkthroughViewController and the module is the project name. – Alexander G Jun 29 '15 at 09:07
  • The exception message is telling you otherwise - you have a UIViewController. – Paulw11 Jun 29 '15 at 09:35
  • I know, but I made 100% sure it was of the class BWWalkthroughViewController! Anyway, I finally gave up and deleted it. Making a new one worked - probably a bug in Xcode that was the culprit. Thanks anyway! – Alexander G Jun 29 '15 at 10:01

1 Answers1

3

The problem was probably a bug in Xcode - my "walk" view controller was of the class BWWalkthroughViewController in IB, but Xcode kept telling me otherwise. I ended up deleting the view controller and making a new one, which worked.

Alexander G
  • 115
  • 9
  • YES. Literally this solved my same exact issue. Been stuck on this crap for 2-3 hours. I removed my ViewController, added a new one, and still wouldn't work until I manually wrote out the Module name (aka your project name) again. Thanks Alexander – trixmasta Nov 29 '15 at 23:54
  • Yes! Beside selecting the class, you also need to specify the module name as BWWalkthrough – John the Traveler Apr 19 '16 at 10:28