Which one is better to use to flow the data from one class to another in the whole project?
NSInvocation
NSNotificationCentre
delegate methods
or by any other methods i am unaware of ??
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
They all exist because they all serve different purposes. Briefly:
NSInvocation
Abstract message send to one object, with optional parameters, represented as an object. Not used very often, particularly since the introduction of blocks.
May also be used as a convenient way to avoid creating an
NSOperationsubclass (seeNSIvocationOperation).NSNotificationCenter
Broadcast a message to any number of unknown ‘listeners’. One to many. Broadcaster need not know about listeners. Includes a user info dictionary for supplemental information. The most heavyweight/slowest of the lot — not needed frequently, but seen often for convenience.
Delegates are sufficient substitutes in many cases.
delegate methods
Typically an abstract object which typically adopts a specific protocol. One to one relationship. Common means to handle an action rather than subclassing.
Blocks
(^)can also be used as callbacks/handlers and often as a more typesafe replacement for NSInvocations.