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

What's the difference between us...

Câu trả lời

Here is an explanation of the differences between using a delegate and notifications in Objective-C:

Delegates

  • Delegates are a one-to-one communication pattern where one object acts on behalf of another object.
  • The delegating object maintains a strong reference to its delegate.
  • Delegates are typically used for responding to specific events or actions that occur in the delegating object.
  • Delegates allow for customization and control over the behavior of the delegating object.
  • Delegates are commonly used in UIKit and Foundation frameworks, such as UITableViewDelegate and NSURLSessionDelegate.

Notifications

  • Notifications are a one-to-many communication pattern where an object can broadcast information to multiple observers.
  • Notifications use a publish-subscribe model, where the broadcasting object does not maintain references to its observers.
  • Observers register themselves to receive notifications of specific types.
  • Notifications are used for broadcasting general information or events that may be of interest to multiple objects.
  • Notifications are commonly used in the `NSNotificati...
senior

senior

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

entry

Name four important data types found in Objective-C

middle

What is the purpose of managed object context NSManagedObjectContext in Objective-C and how does it work?

middle

What mechanisms does iOS provide to support multi-threading?

Bình luận

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

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