Swift Questions et reponses d'entretien
Question 21. What is the role of the 'unowned' keyword in Swift?
The 'unowned' keyword is used in Swift to declare a reference that does not keep a strong hold on the instance it refers to, and it is assumed to always have a value.
Question 22. Explain the concept of generics in Swift.
Generics allow you to write flexible, reusable functions and types that can work with any type, subject to requirements that you define.
Question 23. What are property observers in Swift?
Property observers are used to observe and respond to changes in a property's value, providing a way to execute code before or after the value changes.
Question 24. How does Swift handle memory management compared to Objective-C?
Swift uses Automatic Reference Counting (ARC) for memory management, eliminating the need for manual memory management in Objective-C.
Question 25. Explain the difference between a struct and a class in Swift.
Structs are value types, while classes are reference types. Structs are copied when assigned or passed, whereas classes share a reference to the same instance.
Les plus utiles selon les utilisateurs :
- What is Swift?
- Explain optionals in Swift.
- What is the difference between 'let' and 'var' in Swift?
- What are property observers in Swift?
- What is the purpose of the 'static' keyword in Swift?