[iOS] Handle deep link with chain responsibility pattern
The idea of deep linking is simple. You have an URL click to open your application and navigate to a specific screen. However, it can be messy when it comes to code, and you may end up with something like this. if url.absoluteString.contains("/login") { // Navigate to Login screen } else if url.absoluteString.contains("/products") { // Navigate to Products screen } else if url.absoluteString.contains("/payment") { // Navigate to Payment screen } else { // Navigate to Home screen } You can imagine what happens if you have ten types of URLs. This design also violates the Open/Closed Principle, and every time you add a new URL, you will have to open this file and add one more if-else block. Now is the solution. ...