Hi Guest

MobileUser

1 HomePage 1 Jobs 1 WalkIn 1Articles  

Cat Exam

 :) Latest Topic
AJAX
VB.NET
SQL Query
UDDI
CLASS
JavaScript Questions
SharePoint Interview
SilverLight
WCF
general knowledge
 ASP.NET
 :) Hot Jobs
 
 :) Latest Articles


  

 


Write code to use function AsyncAfter and afterDelay to delay or wait time in Swift?
Question Posted on 27 Aug 2021

Home >> Programming Languages >> Swift >> Write code to use function AsyncAfter and afterDelay to delay or wait time in Swift?




Write code to use function AsyncAfter and afterDelay to delay or wait time in Swift?
(1)Here in first function we use function using AsyncAfter. Below is the block of code after a time delay by using asyncAfter:-

let DelayInseconds = 4.0
DispatchQueue.main.asyncAfter(deadline: .now() + DelayInseconds)
{
  print("This message display after 4 seconds")
  // Put any custom code here
}


(2)Here we call a function after a Wait time. Here function is call after certain period of time:-

let DelayInseconds = 4.0
perform(#selector(delayedFunction), with: nil, afterDelay: DelayInseconds)
@objc func delayedFunction()
{
  print("This message display after 4 seconds")
}
0
0



 
 Input Your Comments Or suggestions(If Any)
 Name
 Email(optional)
 Comments


Other Important Questions
Why we use Swift Programming Language?
Functions definition in Swift Programming Language?
Write code to use function AsyncAfter and afterDelay to delay or wait time in Swift?
Set custom or some specific background colors in Swift Code?
What do you mean by nil-coalescing operator?






 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |