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

Explain types of protocol in Objective-C

expert

Why and in which conditions should we use @autoreleasepool ?

senior

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

Bình luận

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

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