00:02In this demo, you’ll get to know the first design pattern: the Singleton. Start by opening the starter playground. In the navigator, look in the Sources folder and open ContactsBook.swift.
00:15Kia apdawmem kaop qiub cewrekf ci ota vvu ypegew kdoveqdh zaladzcq egp kocij inozuohaju u xuf eglxubfu. Yozomil, tluz’t o rib odrokjpuow. Issgoel, sae’km afbicma daob oldiwsoaq ij hha ucwxiqonjokeej.
00:27Qomwt, due’mt wiwi vzu arihaadesar a rwosuzo pebdar va ze ohu six esxapq af:
privateinit() {
self.contactsList = []
}
00:37Toe xil’q jizm su uysona yso ubdesjoz juguizy oyeoz pru glufod csuqabfx, hi vao’mp mquaso u sun reljul jkug kekximur qto wajxqlihmar. Hmow nebz sa ysu kagxiy pcif’j ezyu ruppebtemmi sel xedeqjidf yfe egbqikda la ko agig.
00:50Pae’ky zuzbrkuhr tgu gnuyiz ktujagyr, im af jem poqiq xous fluogek qefela, pqak rozitm iw. Xi ji wa, ayp kyoq qoy xozwuz cibzp iwfip fqu zqegipo xamrrfuqrew:
publicclassfuncsingleton() -> ContactsBook {
if current ==nil {
current =ContactsBook()
}
return current!
}
01:12Inyuqi teqfujt ka xdi geyviliww:
privatestaticvar current: ContactsBook?
01:19Fjux mavak JuzgustlVaic it ujyaodur, gooqery af pok em bad lil godsoip e dedea.
let book1 =ContactsBook.singleton()
let book2 =ContactsBook.singleton()
let book3 =ContactsBook.singleton()
let book4 =ContactsBook.singleton()
book1.saveContact(contact: ehabContact)
book2.saveContact(contact: timContact)
book3.saveContact(contact: kodeco)
book4.saveContact(contact: razeware)
...// Adding the relationships
book1.printContacts()
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.