YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← 01-19 Which of these needs to be unwrapped

01-19 Which of these needs to be unwrapped

Get Embed Code
1 Language

Showing Revision 2 created 04/08/2015 by Udacity Robot.

  1. Is it true that classes in
    UIKit make use of optionals?
  2. Take a minute, read in
    the documentation to convince yourself.
  3. Let's look up the documentation for
    each of the following items in UIKit and
  4. find out if they're plain old values or
    optionals.
  5. Imagine that we're writing
    code in a view controller,
  6. perhaps inside the viewDidLoad method.
  7. Let's say the viewDidLoad method
    has a button property and
  8. we want to access
    the image in the button.
  9. Buttons can have more than one image.
  10. Let's get the image in the normal state.
  11. The method we would use for
    this is imageForState.
  12. We can look in the UIButton
    documentation to see if this returns
  13. a plain old UIImage reference or
    an optional.
  14. Let's see a few more
    before you start looking.
  15. This is a long one.
  16. It is the image picker controller
    that you'll use in the meme project.
  17. It's a view controller and it has
    a method named isSourceTypeAvailable.
  18. You can look up the
    UIImagePickerController documentation
  19. and see if this method returns
    an optional or a plain old value.
  20. Finally ,view controllers have
    a property that points to
  21. a storyboard object.
  22. It's an object-oriented
    representation of the storyboard.
  23. Look at the UIViewController
    documentation to see if this is a plain
  24. old UIStoryboard reference or
    an optional.
  25. Look into the documentation now and
  26. see what kind of value each of
    these expressions will evaluate to.
  27. See if it's an optional or
    a plain old value type.
  28. If it's an optional, check the box.
  29. If not, you can leave it unchecked.
  30. If you feel stuck, there's some
    advice in the instructor's notes.