Learn about another programming pattern some developers use that's simpler than it looks.
- [Instructor] Dependency injection has got to be … one of the most annoying terms in all of programming. … It describes something that is so blatantly obvious, … we don't even know we're doing it. … Let's look at what dependency injection is … and what it is used for. … If you download the example file, you'll find a playground. … I have two classes here. … We have the pizza class, … uses the size class to get a size. … Put another way, pizza has a dependency of size. … I set initial values for height and width. … So if you run this, … this'll work fine just as it is, … but right now it would only give me an area of 120. … If I want to change the height or width, … I have to make an initializer for size. … So I would go into here and do an init … and then do height double and then width, double. … And then of course self dot height equals height … and self dot width equals width. … Okay, and you'll see … that we get a missing arguments down here. … So I can go ahead and now change those around …
Author
Updated
4/13/2021Released
1/23/2018Note: Because this is an ongoing series, viewers will not receive a certificate of completion.
Skill Level Beginner
Duration
Views
Related Courses
-
Swift: Delegations and Data Sources
with Steven Lipton1h 6m Intermediate
-
New This Week:
-
Photos picker7m 51s
-
-
Introduction
-
Welcome1m 10s
-
-
iOS Development Tips Weekly
-
Use Xcode Git repositories6m 59s
-
Read and write text files6m 47s
-
Use the Xcode 9 simulators4m 24s
-
Layout and iPhone X5m 35s
-
Read JSON files7m 59s
-
Make a camera on iPad7m 50s
-
Motion effects7m 27s
-
Tricks with Asset Manager6m 40s
-
Array tricks10m 56s
-
Image and color literals6m 48s
-
Why use uint8?10m 14s
-
Using hex color9m 39s
-
Deep dive into dictionaries9m 11s
-
Tapping a map7m 3s
-
Update old apps3m 47s
-
Using Apple Pencil8m 42s
-
Using property lists7m 44s
-
Using popovers8m 23s
-
Attributed string jazz9m 18s
-
3D text with SceneKit5m 54s
-
UIColor class extensions5m 46s
-
Timer accuracy6m 25s
-
Animate maps5m 17s
-
Xcode 10 storyboard changes7m 46s
-
Use code snippets8m 40s
-
Customizing the tab bar8m 31s
-
The Settings bundle9m 26s
-
Use the speech synthesizer6m 45s
-
Make round buttons7m 45s
-
Embed table views6m 36s
-
Make a toggle button7m 37s
-
Drop shadows6m 24s
-
Blur and vibrancy effects8m 48s
-
Views in playgrounds6m 52s
-
Launch the Settings app4m 45s
-
Draw paths in UIViews8m 4s
-
CALayer masks7m 14s
-
Protocols and time pickers6m 38s
-
Sliders as knobs7m 36s
-
Fix stackview disasters8m 9s
-
Using haptics4m 57s
-
Test flight9m 8s
-
Replacing segmented controls9m 50s
-
Ranges6m 48s
-
Unicode characters8m 36s
-
Thrown errors9m 41s
-
Actions in table views7m 5s
-
Make and use closures7m 4s
-
Using ARC6m 20s
-
Get BASIC with swift strings7m 56s
-
Convert CSV files10m 7s
-
Strings to doubles8m 14s
-
Enums13m 4s
-
Selection in text views5m 30s
-
Generate QR codes5m 13s
-
String interpolation6m 59s
-
Xcode changes5m 52s
-
Use Dark Mode on storyboards4m 45s
-
Use SF Symbols8m 42s
-
Structs6m 18s
-
Quick SwiftUI8m 55s
-
Working with sets7m 28s
-
Segue Actions4m 38s
-
Checkboxes in SwiftUI6m 15s
-
To-do lists in SwiftUI4m 27s
-
Quick Help in SwiftUI6m 29s
-
Models in SwiftUI6m 38s
-
SwiftUI in Xcode Playgrounds6m 39s
-
Basic PencilKit5m 45s
-
Setter and Getters5m 15s
-
UITextViews and coordinators6m 22s
-
Dark Mode in code6m 1s
-
Candle effects7m 53s
-
RealityKit5m 44s
-
NumberFormatter6m 7s
-
Tuples4m 42s
-
Protocols6m 16s
-
Property wrappers5m 19s
-
iPad to macOS6m 11s
-
Type properties5m 11s
-
SwiftUI animation8m 24s
-
@Binding in public6m 38s
-
SwiftUI ScrollView5m 30s
-
MapKit points of interest6m 14s
-
SF Symbols configuration5m 44s
-
Custom SF Symbols8m 7s
-
Use SwiftUI GeometryReader4m 15s
-
Proportional SwiftUI views8m 22s
-
Custom modifiers in SwiftUI6m 22s
-
Dependency injection6m 28s
-
Xcode themes7m 16s
-
Basic generics5m 58s
-
Selections in watchOS7m 23s
-
SwiftUI borders and shapes8m 54s
-
SwiftUI gradients11m 13s
-
Special parameters8m 49s
-
Overriding operators8m 29s
-
Basic measurements9m 26s
-
Key paths7m 9s
-
Recursive structs8m 38s
-
Outline views in SwiftUI5m 42s
-
TextEditor and Scribble4m 51s
-
Color pickers8m 54s
-
Changes to enums in Swift6m 15s
-
Date pickers6m 54s
-
SwiftUI labels3m 26s
-
SwiftUI maps6m 5s
-
Collection views for SwiftUI3m 50s
-
Scribble bugs4m 48s
-
The joys of UUID5m 8s
-
SwiftUI swipe gesture4m 2s
-
Holiday special: Let it snow6m 17s
-
Embed images in SwiftUI text5m 44s
-
UICollectionView lists11m 24s
-
UICollectionView layout9m 41s
-
Menus on UIButtons10m 27s
-
Multicolor symbols7m 33s
-
Multiplatform Swift UI8m 10s
-
Documents in SwiftUI8m 51s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Dependency injection