This Error Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value [duplicate]












-1















This question already has an answer here:




  • What does “fatal error: unexpectedly found nil while unwrapping an Optional value” mean?

    8 answers




From this line of code: lblQuestion.text = currentQuestion!.question



i am getting this error message -

Fatal error: Unexpectedly found nil while unwrapping an Optional value



i am creating a multiple choice quiz and i am very new to swift so any help would be great.










share|improve this question













marked as duplicate by Rakesha Shastri, Sh_Khan swift
Users with the  swift badge can single-handedly close swift questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 '18 at 13:07


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




















    -1















    This question already has an answer here:




    • What does “fatal error: unexpectedly found nil while unwrapping an Optional value” mean?

      8 answers




    From this line of code: lblQuestion.text = currentQuestion!.question



    i am getting this error message -

    Fatal error: Unexpectedly found nil while unwrapping an Optional value



    i am creating a multiple choice quiz and i am very new to swift so any help would be great.










    share|improve this question













    marked as duplicate by Rakesha Shastri, Sh_Khan swift
    Users with the  swift badge can single-handedly close swift questions as duplicates and reopen them as needed.

    StackExchange.ready(function() {
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function() {
    $hover.showInfoMessage('', {
    messageElement: $msg.clone().show(),
    transient: false,
    position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
    dismissable: false,
    relativeToBody: true
    });
    },
    function() {
    StackExchange.helpers.removeMessages();
    }
    );
    });
    });
    Nov 12 '18 at 13:07


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















      -1












      -1








      -1








      This question already has an answer here:




      • What does “fatal error: unexpectedly found nil while unwrapping an Optional value” mean?

        8 answers




      From this line of code: lblQuestion.text = currentQuestion!.question



      i am getting this error message -

      Fatal error: Unexpectedly found nil while unwrapping an Optional value



      i am creating a multiple choice quiz and i am very new to swift so any help would be great.










      share|improve this question














      This question already has an answer here:




      • What does “fatal error: unexpectedly found nil while unwrapping an Optional value” mean?

        8 answers




      From this line of code: lblQuestion.text = currentQuestion!.question



      i am getting this error message -

      Fatal error: Unexpectedly found nil while unwrapping an Optional value



      i am creating a multiple choice quiz and i am very new to swift so any help would be great.





      This question already has an answer here:




      • What does “fatal error: unexpectedly found nil while unwrapping an Optional value” mean?

        8 answers








      swift






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 '18 at 13:02









      hjphjp123hjphjp123

      1




      1




      marked as duplicate by Rakesha Shastri, Sh_Khan swift
      Users with the  swift badge can single-handedly close swift questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 12 '18 at 13:07


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by Rakesha Shastri, Sh_Khan swift
      Users with the  swift badge can single-handedly close swift questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 12 '18 at 13:07


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


























          1 Answer
          1






          active

          oldest

          votes


















          0














          You are explicitly unwrapping the optional variable currentQuestion. When this variable is nil it will cause a crash.



          Please read the Swift documentation about optional chaining: https://docs.swift.org/swift-book/LanguageGuide/OptionalChaining.html



          You should safely set the text of your label as such:



          lblQuestion.text = currentQuestion?.question





          share|improve this answer




























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You are explicitly unwrapping the optional variable currentQuestion. When this variable is nil it will cause a crash.



            Please read the Swift documentation about optional chaining: https://docs.swift.org/swift-book/LanguageGuide/OptionalChaining.html



            You should safely set the text of your label as such:



            lblQuestion.text = currentQuestion?.question





            share|improve this answer


























              0














              You are explicitly unwrapping the optional variable currentQuestion. When this variable is nil it will cause a crash.



              Please read the Swift documentation about optional chaining: https://docs.swift.org/swift-book/LanguageGuide/OptionalChaining.html



              You should safely set the text of your label as such:



              lblQuestion.text = currentQuestion?.question





              share|improve this answer
























                0












                0








                0






                You are explicitly unwrapping the optional variable currentQuestion. When this variable is nil it will cause a crash.



                Please read the Swift documentation about optional chaining: https://docs.swift.org/swift-book/LanguageGuide/OptionalChaining.html



                You should safely set the text of your label as such:



                lblQuestion.text = currentQuestion?.question





                share|improve this answer












                You are explicitly unwrapping the optional variable currentQuestion. When this variable is nil it will cause a crash.



                Please read the Swift documentation about optional chaining: https://docs.swift.org/swift-book/LanguageGuide/OptionalChaining.html



                You should safely set the text of your label as such:



                lblQuestion.text = currentQuestion?.question






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 12 '18 at 13:07









                BrocoBroco

                397212




                397212