@objc private func DidTapRegister(){
let vc = RegisterViewController()
vc.title="Create Account"
navigationController?pushViewController(vc, animated:true)
navigationController?pushViewController(vc, animated:true)
This is one of the Swift syntaxes called Optical Chaining.
Optical Chaining-The Swift Programming Language
Swift has a number of syntaxes that reduce the fairly complex processing of multiple lines to a single line if you try to write it as it is, and Optional Chaining is one of them.If you write one line above without using Optional chaining, this is what you will see.
if navigationController!=nil{
let navigation=navigationController!
navigation.pushViewController(vc, animated:true)
}
If you are writing in Japanese, "If the navigationController
property nil
has a value of nil
, Unwrap the navigationController
and run the UINavigationController
method pushControl>".
© 2024 OneMinuteCode. All rights reserved.