InterviewSolution
| 1. |
What do you understand about protocols in ios Swift? |
|
Answer» The PROTOCOL is a concept that is similar to a Java interface and is a highly common component of the Swift programming language. A protocol is a set of attributes, methods, and other requirements that are appropriate for a specific activity. The protocol, in its most basic form, is an interface that describes some methods and characteristics. Instead of implementation, the protocol is described as a skeleton of properties or methods. Enumerations, functions, and classes can be used to implement properties and methods. After the structure, ENUMERATION, or class type names, protocols are declared. It is possible to declare both a single and several protocols. COMMAS are used to separate multiple protocols. A protocol can be defined in a similar way to STRUCTURES, enumerations, and classes: Protocol demoProtocol{// the protocol definition will be GOING at this place}Multiple protocols can be defined by separating them using commas: Class demoClass: demoSuperclass, protocolOne, protocolTwo{// the Structure definition will be going at this place} |
|