The dictionary definition of “delegate” (Cambridge) is “to give a particular job, duty, right, etc. Let’s start with a layman’s definition of some terms. In order to help you in understanding how I build my sample delegation code herein, you should read my articles on “Using Swift extensions to manage complexity, improve readability, and increase extensibility (UICollectionView, protocols, and delegates)” and “Understanding Swift 4 protocols and using them in your apps.” For example, when the indicator starts, you could disable your UI when the indicator stops, you could re-enable your UI and, when the user taps the indicator, you could cancel processing-intensive tasks. I’ll show you how to build a user interface (UI) component, a status/progress indicator, which you can display on screen for processing-intensive tasks… AND I’ll show you how you can customize the behavior of the indicator by using delegation. Download the Xcode 9 project with full Objective-C source from GitHub to follow along. My intent here is to show you how delegation works without getting bogged down in some crazy complex example. I’m going to talk about “delegates” and “delegation.” I’ll lead you through a simple example of implementing the delegation design pattern in Objective-C, with full source code, and then show you a more sophisticated scenario.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |