Lab 2 -
Xcode and the View Lifecycle
Github Classroom
Link
Setup and Background
After accepting the Github classroom asssignment and cloning your repository, you should have a folder
named Lab2
in your current directory. Open the folder and double-click the
file named Lab2.xcodeproj
to open the starter code in Xcode.
There are two relevant files in this lab:
ViewController.swift
This file should be familiar, it contains the code laying out our user interface. Some of the syntax in
this file may be unfamiliar to you at this point in the class, and that’s okay! We’ll go over it all by
next lecture. If you do want a head-start on some this content, check out this
page of our website or make a post on Piazza.
Lab2UITests/Lab2UITests.swift
In the project navigator on the left side of your Xcode window, you should see a folder called
Lab2UITests
. Inside that folder, click on the file called
Lab2UITests
. This file contains the code for testing your lab’s correctness once
you’ve finished. To run the tests in this file, simply click on the diamond next to line 10.
What’s Your Name?
Navigate back to ViewController.swift
. You have two tasks to complete in this
file:
- Add
nameStack
to the view. nameStack
is a type
of view called UIStackView
, which allows us to group together several
views and lay them out in a predictable fashion. We’ll go over stack views in more detail next
class.
- Write a function to be called when
enterButton
is tapped & add a
target to enterButton
.
Once you’ve finished the lab, run the tests in Lab2UITests.swift
. You should
get immediate feedback on your implementation. When all the tests pass, commit your work to
submit.
This lab is due on Monday, September 27 at 11:59 pm. As
always, feel free to post on Piazza if you have any questions, or contact us if you need an
extension!
Lab 2 - Xcode and the View Lifecycle
Github Classroom Link
Setup and Background
After accepting the Github classroom asssignment and cloning your repository, you should have a folder named
Lab2
in your current directory. Open the folder and double-click the file namedLab2.xcodeproj
to open the starter code in Xcode.There are two relevant files in this lab:
ViewController.swift
This file should be familiar, it contains the code laying out our user interface. Some of the syntax in this file may be unfamiliar to you at this point in the class, and that’s okay! We’ll go over it all by next lecture. If you do want a head-start on some this content, check out this page of our website or make a post on Piazza.
Lab2UITests/Lab2UITests.swift
In the project navigator on the left side of your Xcode window, you should see a folder called
Lab2UITests
. Inside that folder, click on the file calledLab2UITests
. This file contains the code for testing your lab’s correctness once you’ve finished. To run the tests in this file, simply click on the diamond next to line 10.What’s Your Name?
Navigate back to
ViewController.swift
. You have two tasks to complete in this file:nameStack
to the view.nameStack
is a type of view calledUIStackView
, which allows us to group together several views and lay them out in a predictable fashion. We’ll go over stack views in more detail next class.enterButton
is tapped & add a target toenterButton
.Once you’ve finished the lab, run the tests in
Lab2UITests.swift
. You should get immediate feedback on your implementation. When all the tests pass, commit your work to submit.This lab is due on Monday, September 27 at 11:59 pm. As always, feel free to post on Piazza if you have any questions, or contact us if you need an extension!