Page 71 - Build and run the application

#1

After making the changes in my WorldTrotter application that were listed between pages 69 and 71, building and running the app shows a black screen of nothing in the Simulator. I have created the ConversionViewController.swift file, changed the custom class, created the outlet and the action, and made the necessary connections.

#2

Run the application again. Set your computer down and come back in five minutes. Any difference?

#3

No difference. Waited 20 minutes, and the simulator still shows a black window.

#4

…and there are no warnings or error messages before or after you run your app? No little yellow triangle with an exclamation point at the top of the Xcode editor? I can duplicate what you are seeing, but i get a warning before I run the app, and I get an error message after I run the app.

At some point, did you delete the wrong thing? For instance did you delete the View Controller in the storyboard rather than the View Controller file in the Project Navigator? In the storyboard, is there a big arrow pointing at the left side of the View? For comparison, open up the Quiz app to see the arrow I am talking about.

#5

I ran the app a few times over the last few days.

Sometimes the app gets:

Could not launch “WorldTrotter”
unable to attach

Sometimes the app loads and when I click on the value field and then click a number on the keyboard, the app closes.

Sometimes the app loads and when I click on value and then click a number on the keyboard, I receive:

fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb)

celsiusLabel.text = textField.text

Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

And sometimes, when I click run, I just get a black screen in the simulator.

Note that no code changes have been made, yet I randomly get all the results above.

#6

What about my other questions?

#7

Sorry. No yellow triangles with errors and yes there is a big arrow pointing at the left side of the view.

#8

[quote]Could not launch “WorldTrotter”
unable to attach[/quote]

That sounds like a Simulator issue. Try Simulator>Quit, then rerun your program. What version of Xcode are you using?

[quote]fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb)

celsiusLabel.text = textField.text[/quote]

That means that you forgot to connect an outlet: either the label or the text field is not connected to its @IBOutlet variable. Or, you first connected the label or the text field to its @IBOutlet variable, but subsequently you changed the name of one of those @IBOutlet variables. If you change the name of an @IBOutlet variable, you need to delete the old connection and re-connect the label or text field to the @IBOutlet variable.

If you got a yellow warning before you ran your program, and there was no big arrow pointing at the left side of the View Controller in the storyboard, then I would know the fix. Maybe one of the suggestions above will cure this problem. If not, it sounds like whatever version of Xcode you are running is completely screwed up. If I were you, I would install the version of Xcode that the book uses.

#9

Using Xcode 7.2.1. I’m going to delete the project, and go back to Chapter 3 and re-create everything from scratch, and see what happens. Thanks for all your help and responses.

#10

Ugh. Don’t ever delete a project. Just create a new project, then you can compare them later.

#11

Good point. I will create a new project.

#12

The problem is the author forgot to mention you need to link the var definition in view controller with the label on your canvas.

Please “control-click” your celsius label on your Main.storyboard to the “conversion view controller” then choose clesiusLabel. See: pasteboard.co/qHyLtQN.png

#13

On p. 70 the text says:

Note also that you said to drag in the opposite direction, which is incorrect.