the link that you have for the second part of the tutorial directs to the really old version of the tutorial from 2014. You may want to update that link cause you have the second part of the tutorial updated anyways Nice work!
I saw this great article about the one line singleton in Swift and wanted to share it here. :
The author shows the evolution of the singleton, from the Objective-C singleton using dispatch_once_t, to the single line Swift static class variable.
The important point is the study of the backtrace in order to prove that a static class variable is initialized under the hood using dispatch_once, which haven’t been cleary stated in Apple documentation (just for global variables, but it’s not the same).
Thank you for the heads up and pointing this one out - much appreciated. @lorenzoboaro Can you please take care of and handle this one when you actually get a chance? Thanks! :]
I am coming across issues with this tutorial. I downloaded XCode 9 beta and I am trying this out. but when I used Swift 4.0 the compiler is cribbing and when I set it Swift 3.1 it did not crib. But I also came across another issue on the line:
func addAlbum(_ album: Album, at index: Int) { persistencyManager.addAlbum(album, at: index)strong text
if isOnline {
httpClient.postRequest(“/api/addAlbum”, body: album.description)
}
}
This does not compile. I tried so many ways but has not accepted the same.
These are the errors that it gives.
Wonderful tutorial!! Please help me to get over these issues!! Thanks in advance
Hi @rommex73! Thanks for your feedback and sorry for the delay. The tutorial can be opened in Xcode 9 since I’m using the new Safe Area Layout Guide. That’s a new feature in iOS 11. If you want, you can still open Storyboards in Xcode 8 using the Opens in option under the Interface Builder Document in the File inspector tab. Let me know for anything!
Hi @hemav! Thanks for your feedback! Could you tell me what version of Xcode 9 beta version you are using? The project works fine for me. I’m using Xcode 9 Beta 5. Thanks, Lorenzo
Hey @lorenzoboaro! Thanks for your reply. In fact, you boosted my interest and I installed Xcode Beta ))) So this is not a big deal. I am more concerned about Memento pattern, as I commented in the 2nd part. thanks for your work!!!
In Xcode 8.3.3 you can’t even open the Main.storyboard file to get to the point where you see the Interface Builder Document section of the File Inspector tab.
Is there no way to compile this project in Xcode 8.3.3? I already dropped the deployment target to iOS 10.3 and changed the language back to Swift 3.
Hi @gdubz! Thanks for your feedback. The project has been created with Xcode 9 beta. You can download it from https://developer.apple.com/download/. Swift 4 has been also used. Let me know if you need further info. Thanks, Lorenzo
I copy pasted the question I asked in stackoverflow.
I am following tutorial from raywanderlich site to implement singleton and facade design pattern from this link. https://www.raywenderlich.com/160651/design-patterns-ios-using-swift-part-12 In the tutorial, they hardcoded album data inside init() of the PersistencyManager class. However, in my case I need to call http request to get the data. So the problem now is when the libraryAPI (singleton) create PersistencyManger instance, the init() gonna take few times to fetch the data. So, when my viewcontroller want to call libraryAPI.getAlbum(), it’s gonna be empty. Also I still need to reload data for my viewcontroller. So what’s the best way to implement facade design pattern with http request? I don’t want to do completion block in my viewcontroller, hence I believe the purpose of the facade design patter to hide any thing complex for the viewcontroller