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

When to use NSArray vs NSSet ?

Câu trả lời

Here is an explanation of when to use NSArray vs NSSet in Objective-C:

NSArray

  • Use NSArray when you need an ordered collection of objects and the order of the objects matters.
  • NSArray allows duplicate objects.
  • You can access objects in an NSArray by index.
  • NSArray has methods to add, insert, and remove objects at specific indexes.
  • NSArray conforms to the NSCopying protocol, so you can create copies of arrays.

NSSet

  • Use NSSet when you need an unordered collection of unique objects and the order does not matter.
  • NSSet does not allow duplicate objects. If you add an object that is already in the set, nothing happens.
  • You cannot access objects in an NSSet by index. You ...
middle

middle

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

junior

What is the reuseIdentifier used for?

senior

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

senior

How to create an abstract class 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