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.

iOS_Course_8

413 views

Published on

iOS Design Pattern.
Singleton Pattern.
Delegation Pattern.
MVC Pattern.
Notification Pattern

Published in: Software
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS 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 THIS 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 eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, 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, Ebooks, 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 THIS 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 THIS 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 THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS 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 THIS 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 eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, 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, Ebooks, 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 THIS 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 THIS 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 THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS 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 THIS 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 eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, 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, Ebooks, 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 THIS 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 THIS 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 THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS 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 THIS 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 eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, 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, Ebooks, 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 THIS 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 THIS 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 THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that 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 that 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 eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, 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, Ebooks, 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 That 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 That 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 that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

iOS_Course_8

  1. 1. iOS: Sviluppo App iPhone & iPad Dario Pizzuto 1
  2. 2. iOS Design Pattern 2
  3. 3. Design Pattern Argomenti! • Design Pattern: cosa sono! • MVC! • Delegation! • Singleton! • Notification 3
  4. 4. Design Pattern 4 Cosa sono! • Soluzioni riusabili per problemi comuni nel design del software! • Template che permettono di definire un codice pulito, semplice! • Basati su Best Practices! • Nei linguaggi ad oggetti definiscono relazioni ed interazioni tra oggetti! • Esistono varie tipologie di design pattern
  5. 5. Model-View-Controller (MVC) 5
  6. 6. Design Pattern Model-View-Controller ! • Design Pattern per eccellenza! • Si adatta a molteplici contesti! • Classifica gli oggetti e spinge verso la separazione del codice in base a dei ruoli! ✓Model! ✓View! ✓Controller 6
  7. 7. Design Pattern Model! • Oggetto che definisce il dato nel software ! • Descrive come manipolare il dato! • Es. ! ✓ Album! ✓Documento 7
  8. 8. Design Pattern 8 View! • Oggetto che definisce la visualizzazione del dato ! • Definisce come l’utente può interagire con il dato! • Es. ! ✓ AlbumView! ✓DocumentoView
  9. 9. Design Pattern 9 Controller! • Coordinatore ! • Interagisce con il Model per ricevere le informazioni! • Interagisce con View per definirne la visualizzazione! • Es. ! ✓ AlbumViewController! ✓DocumentoViewcontroller
  10. 10. Design Pattern 10 Model View Controller
  11. 11. Design Pattern Model-View-Controller ! • Il Model notifica al Controller le variazioni del dato! • Il Controller aggiorna il Model in base ai cambiamenti recepiti dal Controller a partire dalla View ! • L’utente esegue delle azioni sulla 11 View
  12. 12. Singleton 12
  13. 13. Design Pattern Singleton! • Design Pattern che assicura l’esistenza di una solo istanza della classe! • Fornisce un punto di accesso globale all’oggetto! • Usato, ad esempio, per gestire uno strato “light” di cache applicativa o il client a REST API 13
  14. 14. Design Pattern 14 Singleton Objects! • Alcuni metodi che restituiscono Singleton! ✓[NSUserDefaults standardUserDefaults]! ✓[UIApplication sharedApplication]! ✓[NSFileManager defaultManager]
  15. 15. Design Pattern Singleton! • In Objective-C è buona norma creare Singleton e registrare il metodo di classe sharedInstance! ! + (instancetype)sharedInstance {! static id instance;! static dispatch_once_t onceToken;! dispatch_once(&onceToken, ^{! instance = [[self alloc] init];! 15 });! return instance;! }
  16. 16. Design Pattern 16 Singleton! • sharedInstance assicura che vi sia una sola istanza della classe! • Controllo eseguito attraverso il blocco di codice dispatch_once! • Accedo all’istanza condivisa includendo la classe con la direttiva #import ed utilizzando! ✓[SingletonClass sharedInstance]
  17. 17. Design Pattern 17 Singleton
  18. 18. Delegation 18
  19. 19. Design Pattern 19 Delegation! • Design Pattern che “sfrutta” un altro oggetto per agire per conto di un oggetto! • Le operazioni da compiere vengono delegate ad un altro oggetto! • Utilizzato per mantenere l’implementazione di specifici comportamenti alla classe di destinazione
  20. 20. Design Pattern 20 Delegation! • È il pattern per eccellenza su iOS! • iOS è ricco di classi che sfruttano il Delegation Pattern! ✓UITableView! ✓UIScrollView! ✓UITextField! ✓UITextView! ✓UIAlertView! ✓....
  21. 21. Design Pattern 21 Delegation! • La classe UITableView, sfrutta il delegate UITableViewDelegate! • Il delegate si occupa di configurare i parametri dell’oggetto! • La classe che contiene la UITableView sarà conforme al delegate UITableViewDelegate
  22. 22. Design Pattern Delegation! • Esiste anche il DataSource ! • Usato per configurare la sorgente dati della classe! • UITableView utilizza UITableViewDataSource per configurare il numero di rows, sections, dimensione delle celle ed altro 22
  23. 23. Design Pattern Esempio Delegation! ! @interface DPPPersonaViewController : UIViewController<UITableViewDelega te,UITableViewDataSource>! @end 23
  24. 24. Notification 24
  25. 25. Design Pattern 25 Notification! • Molto usato in iOS! • Permette di inviare delle notifiche ad N osservatori! • Modello broadcast: lo stesso messaggio viene spedito a chi è in ascolto! • Non è necessario per il notificatore sapere chi sono gli osservatori! • Gli osservatori gestiranno singolarmente la manipolazione dati a seguito della ricezione dell’evento
  26. 26. Design Pattern Notification! • Strumento potente! • Riduce la dipendenza, in senso stretto, tra gli oggetti! • Le notifiche vengono gestite da iOS in modo automatico attraverso l’oggetto NSNotificationCenter 26
  27. 27. Design Pattern 27 Notification
  28. 28. Design Pattern 28 Notification! • Per registrare un osservatore è necessario richiamare il metodo [[NSNotificationCenter defaultCenter] addObserver: selector:name:object:]; ! • Specificare in selector, il metodo che gestirà la ricezione della notifica! • Rimuove l’osservatore quando viene deallocata la classe o non vogliamo più ricevere notifiche sull’osservatore
  29. 29. Design Pattern Registrare una notifica ! [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(manageUpdateMenuNotifi cation:) name:kMenuChangeStatusNotification object:nil];! ! 29
  30. 30. Design Pattern Emettere una notifica [[NSNotificationCenter defaultCenter] postNotificationName:kMenuChangeStatusNot ification object:nil];! 30
  31. 31. Design Pattern ! ! - (void)manageUpdateMenuNotification:(NSNotification *) notification {! if ([[notification name] isEqualToString:kMenuChangeStatusNotification){ ! dispatch_async(dispatch_get_main_queue(),^{! UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];! [cell awakeFromNib];! [self.tableView reloadData];! });! ! }! } 31 Gestire una notifica
  32. 32. Design Pattern Rimuovere l’osservatore - (void)dealloc{! [[NSNotificationCenter defaultCenter]removeObserver:self name:kMenuChangeStatusNotification object:nil];! } 32
  33. 33. Design Pattern Ulteriori approfondimenti! Design Pattern! Modal View Controller! Singleton! Delegation! Notification Programming 33
  34. 34. Domande ? 34

×