This Error Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value [duplicate]
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.
swift
marked as duplicate by Rakesha Shastri, Sh_Khan
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.
add a comment |
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.
swift
marked as duplicate by Rakesha Shastri, Sh_Khan
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.
add a comment |
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.
swift
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
swift
asked Nov 12 '18 at 13:02
hjphjp123hjphjp123
1
1
marked as duplicate by Rakesha Shastri, Sh_Khan
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
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.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
add a comment |
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
add a comment |
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
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
answered Nov 12 '18 at 13:07
BrocoBroco
397212
397212
add a comment |
add a comment |