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

senior

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

senior

Explain the difference between interfaces, delegates, and protocols in Objective-C

senior

What are the differences between implementing a @property with @dynamic or @synthesize ?

Bình luận

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

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