LoginSignup
10
6

More than 3 years have passed since last update.

Segueの遷移がうまく行かなくて詰まった話

Last updated at Posted at 2019-10-17

こちらのUdemyのコースを受講していて、セクション12のプロトコルを深く学ぼうをやっているときに詰まったので備忘録に作成。

プロトコルってこんなんなんだーと思いながら組んで、ビルドしてみたら…
ezgif-1-95c93ecbdc88.gif
画面遷移の所で落ちた…:scream:

スクリーンショット 2019-10-17 22.01.13.png

お馴染みのsignal SIGABRTエラー。
どーせOutletだろうといろいろ調べてみたけど…
スクリーンショット 2019-10-17 22.03.12.png
スクリーンショット 2019-10-17 22.03.36.png
問題なし…:cold_sweat:

どうしたもんかとコードを見返すが、間違ってはいないよう。
やむなく、ログを見てエラーの原因を探ることに。

2019-10-17 21:55:40.781570+0900 ProtocolBasicApp1[1993:91598] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<ProtocolBasicApp1.ViewController: 0x7f85cc60baf0>) has no segue with identifier 'next''
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff23baa1ee __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00007fff50864b20 objc_exception_throw + 48
    2   UIKitCore                           0x00007fff46f0bee7 -[UIViewController shouldPerformSegueWithIdentifier:sender:] + 0
    3   ProtocolBasicApp1                   0x0000000101e1777a $s17ProtocolBasicApp114ViewControllerC4nextyyypF + 410
    4   ProtocolBasicApp1                   0x0000000101e178b0 $s17ProtocolBasicApp114ViewControllerC4nextyyypFTo + 80
    5   UIKitCore                           0x00007fff4757a082 -[UIApplication sendAction:to:from:forEvent:] + 83
    6   UIKitCore                           0x00007fff46f608e5 -[UIControl sendAction:to:forEvent:] + 223
    7   UIKitCore                           0x00007fff46f60c2f -[UIControl _sendActionsForEvents:withEvent:] + 398
    8   UIKitCore                           0x00007fff46f5fb8e -[UIControl touchesEnded:withEvent:] + 481
    9   UIKitCore                           0x00007fff475b4a31 -[UIWindow _sendTouchesForEvent:] + 2604
    10  UIKitCore                           0x00007fff475b6338 -[UIWindow sendEvent:] + 4596
    11  UIKitCore                           0x00007fff47591693 -[UIApplication sendEvent:] + 356
    12  UIKitCore                           0x00007fff47611e5a __dispatchPreprocessedEventFromEventQueue + 6847
    13  UIKitCore                           0x00007fff47614920 __handleEventQueueInternal + 5980
    14  CoreFoundation                      0x00007fff23b0d271 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    15  CoreFoundation                      0x00007fff23b0d19c __CFRunLoopDoSource0 + 76
    16  CoreFoundation                      0x00007fff23b0c974 __CFRunLoopDoSources0 + 180
    17  CoreFoundation                      0x00007fff23b0767f __CFRunLoopRun + 1263
    18  CoreFoundation                      0x00007fff23b06e66 CFRunLoopRunSpecific + 438
    19  GraphicsServices                    0x00007fff38346bb0 GSEventRunModal + 65
    20  UIKitCore                           0x00007fff47578dd0 UIApplicationMain + 1621
    21  ProtocolBasicApp1                   0x0000000101e1a54b main + 75
    22  libdyld.dylib                       0x00007fff516ecd29 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

最初に出てくるこいつが怪しそう…

'Receiver (<ProtocolBasicApp1.ViewController: 0x7f85cc60baf0>) has no segue with identifier 'next''

んで、いろいろ調べてみたけど一向に解決せずに、一週間くらい放置しておりました。
今日一念発起してなんとかやり遂げようと、やっているときにSegueの遷移をたまたま触ったところ、
スクリーンショット 2019-10-17 22.12.27.png
なんか出た…

左を見てみたところ、
スクリーンショット 2019-10-17 22.14.33.png
Identifierの項目が空になっている…no segue with identifier 'next'って…ひょっとしたら…:thinking:
スクリーンショット 2019-10-17 22.17.24.png
ここにnextと入れてみる。すると…
ezgif-1-b630f3442e53.gif
無事画面が遷移し、期待通りの動作に!!:joy:

Identifierの設定ができていなくて、

ViewController.swift
    @IBAction func next(_ sender: Any) {

        performSegue(withIdentifier: "next", sender: nil)

    }

これが動かなかったのですね。

一歩前進&Qiita初投稿でした。

10
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
6