In the sample project, Mark DiFranco implements the class to process location updates. He applies the concepts of single responsibility and dependency inversion to keep the class small, and independent of other classes.
- [Instructor] We'll create a new class,…and we'll call it "SPDLocationProvider".…This class will receive location updates…from the location manager,…and deliver them to other classes in their app.…Once again, we'll start with protocol.…We'll name it "SPDLocationProvider".…
Below it, we'll define our default class.…And then, below that class,…we'll write an extension to have it conform to our protocol.…Remember, this is not entirely required,…it's simply nicer for organizational purposes.…The first thing this class will need…is access to a location manager.…Let's define the property in the class.…
Remember to use the SPDLocationManager,…and not CLLocationManager.…We'll add the initializer so we can set the property.…Since this class is going to be receiving location updates,…we'll set the delegate as well.…We'll set it to ourselves,…and we can write and extension…for the SPDDefaultLocationProvider…to conform to this protocol.…The delegate that we care about…is the SPDLocationManager delegate,…and we'll implement the only method that it requires,…
- Why write unit tests?
- What is dependency injection?
- Using protocols to help with tests
- Handling external dependencies
- Anatomy of a test case
- Writing tests
- Analyzing code coverage
- Visualizing test results
- Writing and extending UI tests
Skill Level Intermediate
1. Dependency Injection
2. Using Protocols
3. Writing Tests
4. UI Tests
- 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.Cancel
Take 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.