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

What's the difference between the atomic and nonatomic attributes?

Câu trả lời

Here is an explanation of the difference between the atomic and nonatomic attributes in Objective-C:

Atomic Attribute

  • The atomic attribute is the default behavior for properties in Objective-C.
  • When a property is declared as atomic, the compiler generates accessor methods (getter and setter) that are thread-safe.
  • This means that if multiple threads access the property simultaneously, the property's value will remain consistent and valid.
  • The atomic implementation uses locks or semaphores to ensure thread safety.
  • However, atomic properties can have a slight performance impact due to the overhead of acquiring and releasing locks.

Nonatomic Attribute

  • The nonatomic attribute is used to explicitly declare that a property is not thread-safe.
  • When a property is declared ...
middle

middle

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

middle

What are some limitations and problems you can face with categories?

expert

Which is the best of GCD, NSThread or NSOperationQueue ?

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