Skip to content

Commit 1d07912

Browse files
committed
Explain how to add a label in Interface Builder
1 parent f4e9fe6 commit 1d07912

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

README.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -478,17 +478,32 @@ Import the module we defined in our `module.modulemap`,
478478
import SwiftHaskell
479479
```
480480

481-
Add a new label to the window in `MainMenu.xib` for us to write
482-
the result of our Haskell function `square` into, and add it as
483-
an `@IBOutlet` to the `AppDelegate`:
481+
Let's add a new label to the window for us to write the result
482+
of our Haskell function `square` into. Open `MainMenu.xib` and
483+
select the window object in the left sidebar to bring it into
484+
view. Then drag in a label from the object library in the right
485+
sidebar into the window:
486+
487+
![Add a label](tutorial/xcode-ib-add-label.png)
488+
489+
Now option-click on `AppDelegate.swift` in the file list to open
490+
it in an assistant editor. Holding the control key, drag the
491+
label from the window into the `AppDelegate` class to add and
492+
connect a new `@IBOutlet`:
493+
494+
![Add and connect the label outlet](tutorial/xcode-ib-add-label-outlet.png)
495+
496+
![Name the outlet](tutorial/xcode-ib-label-outlet-dialog.png)
497+
498+
Adding the outlet will add a new property to the `AppDelegate`:
484499

485500
```swift
486501
@IBOutlet weak var label: NSTextField!
487502
```
488503

489-
We already have our Haskell library's header imported, so we
490-
can just call the exported `square` function. Add this to
491-
`applicationDidFinishLaunching`:
504+
With the `SwiftHaskell` module imported and a label connected,
505+
let's call `square` and display its result in the label. Add
506+
this to `applicationDidFinishLaunching`:
492507

493508
```swift
494509
label.stringValue = "\(square(5))"
19.2 KB
Loading

tutorial/xcode-ib-add-label.png

11 KB
Loading
10.1 KB
Loading

0 commit comments

Comments
 (0)