Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Mac/iOS Design Patterns

9,744 views

Published on

Getting started with Mac/iOS can be hard. This presentation helps you learn the common design patterns used by Cocoa and Cocoa Touch.

  • DOWNLOAD THE BOOK INTO AVAILABLE FORMAT (New Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THE can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THE is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBOOK .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, CookBOOK, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, EBOOK, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THE Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THE the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THE Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THE BOOK INTO AVAILABLE FORMAT (New Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THE can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THE is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBOOK .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, CookBOOK, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, EBOOK, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THE Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THE the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THE Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Follow the link, new dating source: ❶❶❶ http://bit.ly/36cXjBY ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating for everyone is here: ❶❶❶ http://bit.ly/36cXjBY ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Great presentation!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Mac/iOS Design Patterns

  1. 1. Design PatternsRobert Brown@robby_brown
  2. 2. What is a Design Pattern?After working on related problems, patterns oftenappear in the solutions.Formalized description of best practice.
  3. 3. Singleton
  4. 4. What is a Singleton? A singleton is an object that only has one instance for the lifetime of the application. Some things are not safe to have more than one instance running. For example, an updater. Objective-C classes are singletons by design. You can take advantage of this when creating singletons.
  5. 5. Creating a Singleton https://gist.github.com/1116294
  6. 6. Related PatternsAbstract FactoryPlug-in RegistryNotification Center
  7. 7. Delegate
  8. 8. What is a Delegate?A delegate defines the behavior of a generic class.This keeps implementation specific behavior out of thegeneric class.Data sources are similar to delegates, except theydefine content rather than behavior.UITableViews use both a delegate and a data source.
  9. 9. Delegate Interaction UIApplication UIApplication Delegate
  10. 10. Delegate Interaction UITableView UITableView UITableView DataSource Delegate
  11. 11. GotchasUse “assign” instead of “retain” to avoid retain cycles. When using assign, be sure to nullify the delegate reference when deallocating the object.Use “weak” instead of “assign” when using ARC.
  12. 12. Related PatternsData SourceBlock DelegationCallbackChain of ResponsibilityStateFlyweight
  13. 13. Block Delegation
  14. 14. What is Block Delegation?Similar to a delegate object.Rather than give an object that has one or moremethods defined, give a block that has theimplementation of one method.Rule of thumb: If you have three or more delegatemethods, use a delegate. Otherwise, use blockdelegation. Sometimes it’s appropriate to break this rule.
  15. 15. Block Delegation Interaction Object Block 1 Block 2
  16. 16. GotchasWatch out for retain cycles, particularly with “self” __block __unsafe_unretained id selfRef = self; __block __weak id selfRef = self;Don’t forget to copy your blocks. They are created onthe stack.
  17. 17. Related PatternsDelegateCallback
  18. 18. Model View Controller
  19. 19. What is MVC?A strict organization of classes into their different roles. Model: Any underlying data. View: The graphical presentation of the data. Controller: Coordinates the interactions between the views and model.Keeps programs modular and makes it easy to swapout views when needed.
  20. 20. Model View ControllerInterface View Controller Xcode Builder Model Core Data
  21. 21. GotchasSome implementations of MVC have the View andModel directly connected. This can cause infiniteupdate cycles.
  22. 22. Related PatternsObserver
  23. 23. Layers
  24. 24. What is the Layer Pattern? Modules of a program can be organized like a stack of layers. Strict Layering: A layer can only use the layer directly below it. Non-strict Layering: A layer can use any layer below it.
  25. 25. Core Data Layers Application NSManagedObject Subclass NSManagedObject Context NSManagedObject NSPersistentStoreCoordinator NSManagedObjectModel NSPersistentStore XML SQLite Binary In Memory Custom
  26. 26. GotchasOccasionally you may find a need to call up a layer. Todo this, you will need to use dependency inversion.Dependency inversion: A lower layer defines aninterface to interact with other layers. This is often usedwith notifications. An upper layer can register itself toreceive these notifications through the definedinterface.
  27. 27. Façade
  28. 28. What is a Façade?A façade is a single entry point to a complex collectionof classes.Makes interaction with complex collections easier andless dependent on internal implementation.This is the basis of the layer pattern.
  29. 29. External External External Object Object Object FaçadeObject ObjectObject Object Object
  30. 30. Related PatternsClass clusterLayerProxy
  31. 31. Observer
  32. 32. What is an Observer?Sometimes you want to know when an objectchanges.Often used with MVC. When a model object changes, you want to update the view(s) accordingly.The observer pattern is built into every NSObject viaKey-Value Observing (KVO).
  33. 33. GotchasDon’t forget to remove an object as an observer whenthat object is deallocated.
  34. 34. Related PatternsModel View ControllerNotification Center
  35. 35. Proxy
  36. 36. What is a Proxy?A proxy receives actions in behalf of another object.Many types of proxies: Lazy loading proxy Distributed (network) proxy (NSDistantObject) Immutable proxyNSProxy can be used to make any kind of proxyobject.
  37. 37. Lazy Loading Proxy Object Proxy Photo
  38. 38. Distributed Proxy RemoteObject Proxy Network Object
  39. 39. Immutable Proxy Mutable Object Proxy Object
  40. 40. GotchasIf you use NSProxy, you need to be very familiar withmessage forwarding.
  41. 41. Want to Learn More?Design Patterns: Elements of Reusable Object-Oriented Software Every developer should own this book!Cocoa Design Patterns in the Apple Docs
  42. 42. Questions?

×