It’s a type-safe language for protocol-oriented programming
Safe — fast — expressive
Swift language features
do
, guard
, defer
, and repeat
keywordsPOP (Protocol oriented programming)
the protocol is a blueprint of methods.
protocol-oriented is an approach or programming paradigm In Swift, value types are preferred over classes. However, object-oriented concepts don’t work well with structs and enums: a…
Chapter 2 :- Naming
How much time do you spend writing code vs reading code?!
Indeed, the ratio of time spent reading versus writing is well over 10 to 1
“Uncle Bob”
Names are everywhere in software.
We name our variables, our functions, our arguments, classes, and packages.
We name our source files and the directories that contain them.
We name our jar files and war files and ear files.
We name and name and name.
Because we do so much of it, we’d better do it well.
What follows are some simple rules for creating good names.
Basically, don’t…
By default, all methods listed in a Swift protocol must be implementing in a conforming type. However, there are two ways you can work around this restriction depending on your need
The first option is to mark your protocol using the @objc attribute ( this means it can be adopted only by classes, it does mean you mark individual methods as being optional )
@objc protocol PaymentActionViews { @objc optional func hideView(view: UIView)
@objc optional func showView(view: UIView)
func setSelectButton(button: UIButton)}
the second option
write default implementations of the optional methods that do nothing or do default implementation ( this is better option )
protocol Printable{
func canPrint() -> Bool
}extension Printable{ func canPrint() -> Bool{
return true
}
}
You have a conditional that performs various actions depending on object type or properties.
{ if canBook == false{ hideWhileCash() bookedStatus.text = "Locked" paymentTypeStack.isHidden = true process.isHidden = true } else { process.isHidden = false bookedStatus.text = "Unlocked" } if status == true{ turnPaymentOFF() if method == "cash" { self.process.isHidden = false bookedStatus.text = "Unlocked" bookedStatus.textColor = .green self.chooseCash.isHidden = true self.chooseWallet.isHidden = false showWhileOnline() payment = "online" chooseCash.backgroundColor = .orange chooseCash.setTitleColor(.white, for: .normal) } else { self.process.isHidden = true bookedStatus.text = "Locked"…
Clean Swift (a.k.a VIP) is Uncle Bob’s Clean Architecture applied to iOS and Mac projects. The Clean Swift Architecture is not a framework. It is a set of Xcode templates to generate the Clean Architecture components for you. That means you have the freedom to modify the templates to suit your needs.
View Controller starts and ends the VIP cycle sends data to the Interactor though it doesn’t get responses from the Interactor This class has a one-sided interaction with the Presenter View Controller gets responses from the Presenter but can’t transfer anything…
iOS Developer