Câu hỏi phỏng vấn Objective-C
Câu hỏi

What is the difference between copy and retain ?

Câu trả lời

Here is the difference between the copy and retain methods in Objective-C:

copy

  • The copy method creates a new object that is an exact copy of the original object.
  • It is used to create an immutable copy of an object, such as an NSString or NSArray.
  • The copied object has its own memory address and is independent of the original object.
  • If the original object is mutable, the copy method creates a new mutable object with the same contents.
  • The copy method is typically used to ensure that an object's state is not accidentally modified by another part of the code.

retain

  • The retain method increases the reference count of an object, indicating tha...
junior

junior

Gợi ý câu hỏi phỏng vấn

junior

What is a protocol, and how do you define your own and when is it used?

middle

What are some limitations and problems you can face with categories?

senior

What are the reasons for using NSOperationQueue over GCD and vice versa?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào