Swi Interview Questions for Freshers List some advantages and disadvantages of using ios Swi


Download 0.71 Mb.
Pdf ko'rish
bet17/27
Sana09.10.2023
Hajmi0.71 Mb.
#1696547
1   ...   13   14   15   16   17   18   19   20   ...   27
Bog'liq
0b951f3e909d09b66eb8f74930008ded79a64d5e79248dc67824bd9e2aadd4fa

Swi Interview Questions
Remember that Self with a capital S refers to any type that follows the protocol.
Because Int conforms to SquareInteger in the example above, when called on Int, the
method returns an Int. Self with a lowercase S, on the other hand, refers to the type's
current value. If the preceding example were run on an Int containing the value 4, the
result would be 4 * 4.
24. State your understanding of delegates in ios Swi .
Delegate, in ios Swi , is a design pattern that allows data or communication to be
passed across structs or classes. Delegate allows one object to deliver a message to
another when a certain event occurs, and it is used to handle table and collection
view events. Delegates have a one on one interaction and communicate with one
another. 
An example of a delegate is given below:
// Defining a custom delegate known as SeeActionDelegate 
protocol SeeActionDelegate { 
// Defining the required delegate variables 
var state: GetState { get } 
var userIdentity: String? { get set } 
// Defining the required delegate blocks 
var errorHandler: ((Error) -> Void)? { get set } 
// Defining the required delegate functions 
func handle(action: GetAction) 
}
The enums used in the above delegate are:
enum GetState { 
case `default` 
case loading 

enum GetAction { 
case saved 
case canceled 
}
25. How can the double question mark symbol "??" be used in
ios Swi programming?
Page 23
© Copyright by Interviewbit


Swi Interview Questions
The nil-coalescing operator "??" is a shorthand for the ternary conditional operator,
which we used to test for nil. A double question mark can also be used to set a
variable's default value.
"default string" stringVar??
This does precisely what you would expect: if stringVar is not nil, it is returned;
otherwise, the "default string" is returned.

Download 0.71 Mb.

Do'stlaringiz bilan baham:
1   ...   13   14   15   16   17   18   19   20   ...   27




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling