Differentiate between ‘assign’ and ‘retain’ keyword.
Answer / Prem Singh Jat
In Objective-C, both 'assign' and 'retain' are memory management keywords used with properties. However, they have different usage:
1. 'assign': It implies that the property should manage its own memory by using copy semantics for any setter method implementation.n - Default behavior: If not specified, 'assign' is assumed.n - When to use: Use 'assign' when setting simple types like NSNumber, NSString, or BOOL, which are immutable and do not require retaining.
2. 'retain': It implies that the property should retain its value during its lifetime.n - When to use: Use 'retain' when setting objects that can be mutated, like custom classes or collections.
| Is This Answer Correct ? | 0 Yes | 0 No |
How core data works to save data in persistent storage?
What is App Bundle?
Explain how app delegate is declared by Xcode project templates?
Explain why delegates and notifications are different.
What is difference between category and extension in ios?
What is singleton in ios swift?
What ios version onwards arc can be used?
Describe what “app thinning” means ?
What coding language is used for ios apps?
How many bytes we can send to apple push notification server?
What is dynamic typing in iOS operating system?
What are the ios devices?