Database Reference
In-Depth Information
favoriteLabel
.
hidden
= !bowtie.
isFavorite
.
boolValue
view
.
tintColor
= bowtie.
tintColor
as
UIColor
}
There's a UI element for every one of the attributes defined in a bow tie. Since Core
Data only stores the image as a blob of binary data, it's your job to reconstitute it
back into an image so the view controller's image view can use it.
Similarly, you can't use the
lastWorn
date attribute directly. You first need to create
a date formatter to be able to turn the date into a string that humans can
understand.
Finally, the
tintColor
transformable attribute that stores your bow tie's color
changes the color of not one, but
all
the elements on the screen. Simply set the tint
color on the view controller's view and voila! Everything is now tinted the same
color.
Build and run the app. The red bow tie appears on the screen, like so:
The Wear and Rate buttons do nothing. Tapping on the different parts of the
segmented controls also does nothing. You've still got work to do!
First, you need to keep track of the currently selected bow tie so you can reference
it from anywhere in your class. Add a new property to do this
below
var
managedContext: NSManagedObjectContext!
:
var
currentBowtie:
Bowtie
!
Next, replace the last
if-let
statement in
viewDidLoad
to use your new property:
//4
if
let
bowties = results {