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

expert

What sending a message to nil means and how is it actually useful?

senior

What is the difference between ARC (automatic reference counting) and GC (garbage collection)?

junior

Explain types of protocol in Objective-C

Bình luận

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

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