Get some more practice connecting views from your storyboard to outlets that you can access from Swift code.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5993-your-first-ios-app/lessons/18
Get some more practice connecting views from your storyboard to outlets that you can access from Swift code.
Thank you for the great challenge again! Could you elaborate more on
func updateLabels() {
targetLabel.text = String(targetValue)
I don’t quite get the .text & the reason we have to change Int value to String value.
@jongwon.kim You can’t assign targetValue
to the label’s text
property directly because they are different types: targetValue
is an Int
and text
is a String
:
https://developer.apple.com/documentation/uikit/uilabel/1620538-text
You first have to cast targetValue
to a String
before assigning it to the label’s text
property.
Please let me know if you have any more questions or issues about the whole thing. Thank you!
Great tutorial! With respect to the Your First iOS app - Part 18:Challenge:
I’m getting this message even when I copy and paste the downloaded course material on line 56 of the .swift file:
Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
Also, in the Main storyboard, when I right-click the display label in order to connect the New Referencing Object to the View Controller, I am not getting a “targetLabel” option…only a “view” option.
Please help
@paulpersad Does this happen when you run the sample project as well?