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

middle

What mechanisms does iOS provide to support multi-threading?

middle

A grandparent, parent and child problem

senior

Why delegate is never retained?

Bình luận

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

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