Can't cast value of type UIViewController to PatternDetailViewController

前端 未结 8 1614
孤街浪徒
孤街浪徒 2020-12-06 04:29

Am trying to downcast a view controller to a detail view controller but can\'t. Am using Core Data (for the first time). The error is in the prepareForSegue method and reads

相关标签:
8条回答
  • 2020-12-06 05:01

    Try clean Product > Clean

    Edit: I came across the same error message and it was fixed using this method. This answer may not specifically answer the question

    0 讨论(0)
  • 2020-12-06 05:02

    I solved the issue by following these steps:

    1. Find the source Scene in the storyboard. Go to Identity Inspector (Third tab in the right panel)
    2. Remove (Cut/ctrl+x) the "Class" under "Custom Class" from the Identity inspector.
    3. Switch to another scene.
    4. Switch back to source scene.
    5. Paste the custom class module you just removed.
    6. Exit XCode.
    7. Open Xcode.
    8. Clean.
    9. Build.

    Why did it work? I was copy-pasting someone else's work. I probably wrote Class name in the right hand panel before there was a class with that name. My guess is Swift can not find these kinds of things dynamically. You have to behave like it wishes. You have to do certain things in a certain order.

    0 讨论(0)
提交回复
热议问题