Code from ios CodeSchool slides.