Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Hello Guys , I hope you all are enjoying mobikul blogs.
In today’s blog we will write a small program about the use of typealias in swift.
Now the first thing is “What is typealias and how to use it in our programming?”. Your answer is written below.
Typealias – A type alias declaration introduces a named alias of an existing type into your program. Type alias declarations are declared using the keyword typealias and have the following form:
typealias name = existing type
eg. typealias myDataType = String
ok , lets start by understanding the following code.
Alright guys lets dive into the code and learn whats happening here.
typealias test = (Bool?) -> Void
Created a test named typealias of type (Bool?)->Void
typealias stringType = String
Created a stringType named typealias of type String
The above function will take test type parameter and will call it.
The function callvalueFalse will take two parameters of type test and stringType and will call the test after 3 seconds.
the @escaping keyword represents that our closure will escape the function means first the function will complete and on its completion the closure will get executed.
now inside our button action we called the functions.
self.valueLabel.text = “false”
the false text is assigned to label after 3 seconds because the callvalueFalse functions closure will get executed after 3 seconds.
i.e why we declared escaping there.
Thats enough guys If you have any confusion please comment below.
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.
Osama
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.